Compact join with new line

I would like to compact join address elements by inserting a new line between them

in my class address I am using

   def to_s
     [@street, @city, @country ].compact.join(" - ")
   end

but I'd like to replace " -" by a new line character to display the full adress on 3 lines

is it possible ?

joss

def to_s
    [@street, @city, @country ].compact.join("\n")
  end

···

On 14/09/06, Josselin <josselin@wanadoo.fr> wrote:

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

   def to_s
     [@street, @city, @country ].compact.join(" - ")
   end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

joss

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

   def to_s
     [@street, @city, @country ].compact.join(" - ")
   end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

Well I hope so :wink:
%w{ here you go my friend}.join("\n")

HTH
robert

joss

···

On 9/14/06, Josselin <josselin@wanadoo.fr> wrote:

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

thanks .. that's what I did, but I realize that displaying it inside a Rails view, I should join with a "<br />"
;-))

···

On 2006-09-14 19:13:42 +0200, "Farrel Lifson" <farrel.lifson@gmail.com> said:

On 14/09/06, Josselin <josselin@wanadoo.fr> wrote:

I would like to compact join address elements by inserting a new line
between them

in my class address I am using

   def to_s
     [@street, @city, @country ].compact.join(" - ")
   end

but I'd like to replace " -" by a new line character to display the
full adress on 3 lines

is it possible ?

joss

  def to_s
    [@street, @city, @country ].compact.join("\n")
  end