From: "W. James" Date: 2009-12-14T16:15:06+09:00 Subject: Re: How to write this correctly? Ruby Newbee wrote: > Oh sorry I have found that. > need to convert the arguments to an array. > > "Hello, %s %s" %(["Matz!","again"]) > => "Hello, Matz! again" > > > > On Mon, Dec 14, 2009 at 3:03 PM, Ruby Newbee > wrote: > > Hi, > > > > In python this is right: > > > >>>> "Hello, %s %s" %("Matz!","again") > > 'Hello, Matz! again' > > > > > > But in ruby it will get wrong: > > > > "Hello, %s %s" %("Matz!","again") > > SyntaxError: (irb):39: syntax error, unexpected ',', expecting ')' > > "Hello, %s %s" %("Matz!","again") > >                         ^ > >        from /usr/bin/irb:12:in `
' > > > > > > > > So what's the correct syntax for this case? > > Thanks. > > "Hello, %s %s" % ["Matz!", "again"] ==>"Hello, Matz! again" "Hello, %s %s" % %w(Matz! again) ==>"Hello, Matz! again" --