aris
June 20, 2012, 11:27pm
1
I cannot find an answer to this, and perhaps the answer is that “it is
what it is…” But perhaps someone can explain this for me.
If I have an array, thus:
a = [1, 2, 3, 4]
there are four elements in the array. The indexes are 0…3.
a[4,0] returns []
a[5,0], however, returns nil
Both of these are outside the scope of the array, aren’t they? I would
think they would return the same thing, either nil or the empty array.
Any help? Thanks!
John
Am 20.06.2012 23:27, schrieb John R.:
Both of these are outside the scope of the array, aren’t they? I would
think they would return the same thing, either nil or the empty array.
Maybe this helps:
http://stackoverflow.com/questions/3568222/array-slicing-in-ruby-looking-for-explanation-for-illogical-behaviour-taken-fr
Regards,
Marcus
Am 20.06.2012 23:38, schrieb Bartosz Dziewoński:
See this post for an explanation: String/array slices - Ruby - Ruby-Forum
This behavior definitely should be documented in the Array class.
On 06/20/2012 11:07 PM, [email protected] wrote:
Am 20.06.2012 23:38, schrieb Bartosz Dziewoński:
See this post for an explanation:
String/array slices - Ruby - Ruby-Forum
This behavior definitely should be documented in the Array class.
Good idea. Here’s how:
-Justin
On 06/21/2012 11:13 PM, [email protected] wrote:
Is this obsolete:
http://www.ruby-doc.org/documentation-guidelines.html ?
Regards,
Marcus
That site looks more specific to ruby-doc.org (e.g., using “stdlib-doc”
to generate docs, instead of rdoc). I don’t know if following those
instructions will work or not. The instructions in the link I sent will.
-Justin
Am 22.06.2012 00:56, schrieb Justin C.:
On 06/20/2012 11:07 PM, [email protected] wrote:
…
This behavior definitely should be documented in the Array class.
Good idea. Here’s how:
Ruby Documentation Project
Is this obsolete:
http://www.ruby-doc.org/documentation-guidelines.html ?
Regards,
Marcus
It’s always humbling when you realize other people have thought through
complicated stuff before you.
Dave
A late update: I submitted a patch for the documentation,
see https://bugs.ruby-lang.org/issues/6680