From: Jessica Colnago Date: 2010-11-22T19:41:15+09:00 Subject: proc question Hi there, I'm trying to create a parser that creates a statemachine, using the statemachine gem, from a scxml file. But I got stuck when I started dealing with proc. I can't understand why it works when I do this: action = @actions.last procedure = proc {@@logger.puts action if (action and @@logger)} But not work when I do this: action = @actions procedure = proc { action.each do |a| case a[0] when 'log' @@logger.puts a[1] when 'send' @@queue.send(a[1], a[2]) end end } (at first I was only dealing with one possibility ('log') and now I'm trying to make it able to treat multiple possibilities.) I then use 'procedure' as a parameter here: if (@transitions.last.target != nil) # if it has a target state @state.last.event(@transitions.last.event.to_sym, @transitions.last.target.to_sym, procedure) else # it is its own target state @state.last.event(@transitions.last.event.to_sym, @state.last.id.to_sym, procedure) end Best regards, Jessica -- Posted via http://www.ruby-forum.com/.