On Mon, Jun 29, 2009 at 8:20 AM, Ibon Castilla<ibon.castilla / gmail.com> wrote: > Hi there: > > I was learning about methods, and when I was trying to use optional > arguments I get stucked with this: > > def my_method (a='This', b='is', c='great') > ¨Âõôá«§«â«§«> end > > If I try: > ¨Âùßíåôèï䨧Òõâù§© > > Ruby is great > > nil > > But if I try: > ¨Âùßíåôèï䨬¬§ãïïì§© > > SyntaxError: compile error > > Any idea on how to use arguments different from the first one?. > > Thank's in advance, Ibon. > -- > Posted via http://www.ruby-forum.com/. Optional arguments must be passed in the order they're declared, and cannot be omitted. Instead, you'll often see hashes used instead. def my_method(options={}) o = { :a => 'This', :b => 'is', :c => 'cool' }.merge(options) puts "#{o[:a]} #{o[:b]} #{o[:c]}" end my_method( :c => 'great' )