D
Dark Ambient
What would be the proper call to a multi array either collect or map ?
TIA
Stuart
TIA
Stuart
What would be the proper call to a multi array either collect or map ?
Hi --
There's no single proper thing to do; it depends entirely on the task
at hand.
Hi --
What would be the proper call to a multi array either collect or map ?
There's no single proper thing to do; it depends entirely on the task
at hand.
David
--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
I know they are interchangeableDA, note also that map and collect are synonyms. It doesn't matter which
of
the two you use.
But I can't make it work.
For instance -
x = [["john", "doe"],["mary", "jane"],["jim","richards"],['sue","scott"]]
y = x.map {|i| i + "name" }
p y
It's returning nil on me ????
Dark said:def publishers
editions.map {|e| e.publisher}.uniq
end
I know they are interchangeable
But I can't make it work.
For instance -
x = [["john", "doe"],["mary", "jane"],["jim","richards"],['sue","scott"]]
y = x.map {|i| i + "name" }
p y
It's returning nil on me ????
Try
x = [["john", "doe"],["mary", "jane"],["jim","richards"],["sue","scott"]] #
<= "sue" not 'sue"
y = x.map {|i| i << "name" }
p y
Hi --
I know they are interchangeable
But I can't make it work.
For instance -
x = [["john", "doe"],["mary", "jane"],["jim","richards"],
['sue","scott"]]
y = x.map {|i| i + "name" }
p y
It's returning nil on me ????
Try
x = [["john", "doe"],["mary", "jane"],["jim","richards"],
["sue","scott"]] # <= "sue" not 'sue"
y = x.map {|i| i << "name" }
p y
The disadvantage of that is that it changes the original objects
inside x.
David
--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
You're right. Shouldn't use << in this case. If OP wanted x
modified, then could have just written:
x = [["john", "doe"], ["mary", "jane"], ["jim","richards"],
["sue","scott"]]
x.each {|i| i << "name"}
Regards, Morton
Hi --
On Aug 12, 2006, at 11:08 AM, Dark Ambient wrote:
I know they are interchangeable
But I can't make it work.
For instance -
x = [["john", "doe"],["mary", "jane"],["jim","richards"],
['sue","scott"]]
y = x.map {|i| i + "name" }
p y
It's returning nil on me ????
Try
x = [["john", "doe"],["mary", "jane"],["jim","richards"],
["sue","scott"]] # <= "sue" not 'sue"
y = x.map {|i| i << "name" }
p y
The disadvantage of that is that it changes the original objects
inside x.
David
--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.