From: dblack@... Date: 2006-10-10T17:52:48+09:00 Subject: Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to Hi -- On Tue, 10 Oct 2006, Yukihiro Matsumoto wrote: > I wrote: > > |The possible problem with to_values is that it suggests that what was > |there before the conversion was *not* values, which I think might be > |misleading. to_args still seems too specific to me -- for example, in > |this: > | > | [*0...10] > | > |there's nothing arg-related about what's happening to the range. > > It was *a value* before conversion. I see what you mean. > |I also have a question about the use of this method. Do you think it > |would always be defined in terms of the * itself? In other words: > | > | class C > | def initialize(a) > | @array = a > | end > | def to_values > | *a > | end > | end > | > |But then wouldn't it just return an array? Or would the * still > |un-array it? > | > | c = C.new([1,2,3,4]) > | Hash[*c] # == Hash[1,2,3,4] ? > | > |But then... why have a separate definition? I'm sure there's a reason > |-- I'm just not yet seeing how one would use it. > > I am not sure I understand you here. Here's little bit modified your > example. > > class C > def initialize(a) > @array = a > end > def to_values > @array > end > end > > c = C.new([1,2,3,4]) > Hash[*c] # == Hash[1,2,3,4] > > Do you see any problem? No, I think I got myself twisted around an extra * :-) David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org