Re: Shorter version for this newbie code...?


Then… How can remove last ‘,’ easily?

for example, with array

a = [“a”, “b”, “c”]

I want to get a string “‘a’, ‘b’, ‘c’”.

but{|item| “'” + item + “',”} gives “‘a’, ‘b’, ‘c’,”.

I want to remove last ‘,’.

What is the best way to achieve this?


<-----Original Message----->

From: [email protected]
To: [email protected]
Sent: 2006-08-21 03:03
Subject: [Rails] Re: Shorter version for this newbie code…?

Hi –

On Sun, 20 Aug 2006, Daniel H. wrote:

<%= %>,

What’s wrong there? And how do I get rid of the comma at the end of the
enumeration in an elegant way? I know there’s join(…), but this as
long as I only get those strange
#ShowType:0x22cd910#ShowType:0x22cd8d4 and so on this doesn’t help
me much. :wink:

Try <%= profile.show_types.join(‘,’) %>

I think he wants to harvest the name attributes, like:

<%= {|s| }.join(“,”) %>

David => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <----- => D[avid ]A[. ]B[lack’s][ Web]log
Ruby for Rails => book, Ruby for Rails => Ruby Central, Inc.

»õ·Î¿î ±âºÎ ¹®È­ÀÇ ¾¾¾Ñ, ÇØÇǺó

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at