From: Yukihiro Matsumoto Date: 2006-10-10T17:03:47+09:00 Subject: Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to Hi, In message "Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to" on Tue, 10 Oct 2006 10:47:43 +0900, dblack@wobblini.net writes: |> |I like to_list. It's specific enough that misuse/overuse will be |> |evident. And even though "list" isn't a core class, it's a noun and |> |also much more meaningful than "splat". |> |> Well, that name assumes we are converting an object into a list which |> in reality an array. | |I'm thinking of a list as a kind of unwrapped array. So, for example: | | Hash[1,2,3,4] # a list of four numbers -- no array involved | Hash[*[1,2,3,4]] # an array originally, but unarrayed into | # a list of numbers Understandable. But some may feel different from the word List, for example Linked List or something. |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 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? matz.