ooops. sorry. should be
@myhash.collect {|k,v| "#{k} is #{v}"}.join
On Wed, Feb 16, 2011 at 8:19 AM, Jim Ruther Nill wrote:
> can't you use collect? and then join the result?
>
> @myhash.each {|k,v| "#{k} is #{v}"}.join
>
>
> On Wed, Feb 16, 2011 at 12:46 AM, Paul Bergstrom wrote:
>
>> Why does
can't you use collect? and then join the result?
@myhash.each {|k,v| "#{k} is #{v}"}.join
On Wed, Feb 16, 2011 at 12:46 AM, Paul Bergstrom wrote:
> Why does this output the same hash again (like hash.inspect) and not
> each key as I want?
>
> @myhash.each { |k,v| "" + k + "" }
>
> --
> Posted vi
Or since only keys are needed, use each_key iterator.
Also, I think ri should say that the "method" each "returns" the same Hash
on which you called the method.
-Kedar
On Tue, Feb 15, 2011 at 8:57 AM, Colin Law wrote:
> On 15 February 2011 16:46, Paul Bergstrom wrote:
> > Why does this output
On 15 February 2011 16:46, Paul Bergstrom wrote:
> Why does this output the same hash again (like hash.inspect) and not
> each key as I want?
>
> @myhash.each { |k,v| "" + k + "" }
Because it is showing the return value of the method each, not what
you are doing in the block. You need to build u
Why does this output the same hash again (like hash.inspect) and not
each key as I want?
@myhash.each { |k,v| "" + k + "" }
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group
5 matches
Mail list logo