Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Patrick Tyler Newsgroups: comp.lang.ruby Subject: string/array slices Date: Wed, 30 Mar 2011 12:34:39 -0500 Organization: Service de news de lacave.net Lines: 34 Message-ID: <303f109bd62c19b354717039ac8af1a8@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1301506494 7153 65.111.164.187 (30 Mar 2011 17:34:54 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Wed, 30 Mar 2011 17:34:54 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 380623 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <303f109bd62c19b354717039ac8af1a8@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:1980 Hello, I know that this has been covered a bit here: http://www.ruby-forum.com/topic/186437 but I'm still not certain that I understand. s = "foo" s[3] is nil, like I would expect. s[3,0] is "", instead of nil. s[4,0] is finally nil. I don't understand how I'm indexing '3' in the context of [3,0] and getting anything but nil. Since s[3] is already nil in the first place. Same for arrays: a = [:one, :two] a[2] is nil a[2,0] is an empty array ?? a[3,0] is finally nil though. I understand that in the docs these are special cases and they're not preventing me from working or anything like that. I am just curious to understand the why/how about them working this way. Thank you! -- Posted via http://www.ruby-forum.com/.