D
Daniel Berger
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
Ruby 1.8.4 and 1.8.5
The docs for String#slice! say, "The forms that take a Fixnum will raise
an IndexError if the value is out of range."
However, I cannot duplicate this behavior. Whenever I try to force an
IndexError, I just get back nil, i.e. the same behavior as String.slice.
irb(main):001:0> VERSION
=> "1.8.4"
irb(main):002:0> s = "hello"
=> "hello"
irb(main):003:0> s.slice!(-5,-99)
=> nil
irb(main):004:0> s
=> "hello"
irb(main):005:0> s.slice!(-5,100)
=> "hello"
irb(main):006:0> s
=> ""
I tried a few other things with no luck. Am I missing the proper test case?
Thanks,
Dan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFFiLDq3p/dorzCFX0RAtzeAJ9M8622KzUTHfeiwAQPdjcthjmrMACeO3qk
v/9pNgyUiGziHHgi1Vlht9w=
=lGlO
-----END PGP SIGNATURE-----
Hash: SHA1
Hi all,
Ruby 1.8.4 and 1.8.5
The docs for String#slice! say, "The forms that take a Fixnum will raise
an IndexError if the value is out of range."
However, I cannot duplicate this behavior. Whenever I try to force an
IndexError, I just get back nil, i.e. the same behavior as String.slice.
irb(main):001:0> VERSION
=> "1.8.4"
irb(main):002:0> s = "hello"
=> "hello"
irb(main):003:0> s.slice!(-5,-99)
=> nil
irb(main):004:0> s
=> "hello"
irb(main):005:0> s.slice!(-5,100)
=> "hello"
irb(main):006:0> s
=> ""
I tried a few other things with no luck. Am I missing the proper test case?
Thanks,
Dan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFFiLDq3p/dorzCFX0RAtzeAJ9M8622KzUTHfeiwAQPdjcthjmrMACeO3qk
v/9pNgyUiGziHHgi1Vlht9w=
=lGlO
-----END PGP SIGNATURE-----