On Sat, Feb 23, 2013 at 9:52 AM, Bartosz DziewoĆski <[email protected]> wrote:
> On Sat, 23 Feb 2013 07:08:05 +0100, Matthew Kerwin <[email protected]>
> wrote:
>
>> Splat is an array, Rang is not an array.
>
>
> Matthew, what? This doesn't even make sense.
It does, because
irb(main):004:0> Range.instance_method :to_ary
NameError: undefined method `to_ary' for class `Range'
from (irb):4:in `instance_method'
from (irb):4
from /usr/bin/irb:12:in `<main>'
and, as our friend would have learned a few days back if he followed
the advice to use set_trace_func to learn what's going on
irb(main):015:0> o = Object.new
=> #<Object:0x802a7a80>
irb(main):016:0> def o.to_ary; [1,2,3,4] end
=> nil
irb(main):017:0> a, *b, c = o
=> #<Object:0x802a7a80>
irb(main):018:0> a
=> 1
irb(main):019:0> b
=> [2, 3]
irb(main):020:0> c
=> 4
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--
[email protected] |
https://groups.google.com/d/forum/ruby-talk-google?hl=en
---
You received this message because you are subscribed to the Google Groups
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.