Удалить последние 2 символа из строки в Ruby?

13
задан Tom Lehman 8 September 2009 в 07:26
поделиться

2 ответа

Use join:

def self.all_email_addresses
  User.all.collect {|u| u.email}.join ', '
end
26
ответ дан 1 December 2019 в 17:18
поделиться

remove the last two characters

str.chop.chop # ...or...
str[0..-3]

Although this does answer the exact question, I agree that it isn't the best way to solve the problem.

28
ответ дан 1 December 2019 в 17:18
поделиться
Другие вопросы по тегам:

Похожие вопросы: