String#slice! doc bug?

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-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Array#slice! bug? 0
IO.pos bug? 5
is it bug? 3
Inheriting Array and slice() behaviour 41
Object#method and super. Is this a bug? 10
Strange bug in irb1.9 7
what does print call internally? 12
Socket hang in thread 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top