------ art_4056_9203299.1184160714138 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/7/11, Stefan Rusterholz <apeiros / gmx.net>: > > Ronald Fischer wrote: > > I have problems passing a HERE document as the first parameter > > to a function expecting more than 1 parameter. Example: > > > > # This is file here1.rb > > def q(a,b) > > end > > q(<<-END > > line1 > > line2 > > END > > ,'x') > > > > > > Executing this program yields the error messages > > > > ./here1.rb:9: syntax error, unexpected ',', expecting ')' > > ,'x') > > ^ > > ./here1.rb:9: syntax error, unexpected ')', expecting $end > > > > > > Using a temporary variable to hold the content of the HERE > > string works fine though: > > > > temp -END > > line1 > > line2 > > END > > q(temp,'x') > > > > > > Bug in Ruby? Or do I misunderstand something in the workings of the > > parser? > > > > Ronald > > Not a bug in the parser, just wrong usage. > q(<<-END, 'x') > line1 > line2 > END > > That will work. > > Regards > Stefan > > -- > Posted via http://www.ruby-forum.com/. > > HERE document as second parameter works: irb(main):072:0> def q(a,b) irb(main):073:1> puts a irb(main):074:1> puts b irb(main):075:1> end nil irb(main):076:0> q('1',<<-END irb(main):077:1" 2 irb(main):078:1" END irb(main):079:1> ) 1 2 nil If correctness of usage depends on parameters order - is this a bug? ------ art_4056_9203299.1184160714138--