From: shreeve@...2s.org (Steve Shreeve) Date: 2002-02-26T16:05:14+09:00 Subject: Question with for loop I've got a quick question. Sort of a minor issue, but I was wondering about Ruby's syntax a special situation. I have a bit of code that looks like this: b.rpc('ORWU TOOLMENU',[nil]) b.rpc('ORWU HASKEY',['XUPROGMODE']) b.rpc('ORQQPX NEW REMINDERS ACTIVE') ['O RX', 'I RX', 'UD RX', 'IV RX'].each { |val| b.rpc("ORWORDG IEN", [val]) } b.rpc('ORWU DT', ['NOW']) b.rpc('ORWCH LOADAL') Notice how the third to last line is sort of "doing it's own thing". It would be nice have all these lines "look the same". Something like this would work: b.rpc("ORWORDG IEN", [val]) for val in ['O RX', 'I RX', 'UD RX', 'IV RX'] But, I'm not sure if there is anything like this in Ruby. Are there major scoping issues why something like this will never be valid? I know this is a real nit-picky question, but since Ruby does so many other things wonderfully, I was just curious to ask. If so, my code can happily be written as: b.rpc('ORWU TOOLMENU',[nil]) b.rpc('ORWU HASKEY',['XUPROGMODE']) b.rpc('ORQQPX NEW REMINDERS ACTIVE') b.rpc("ORWORDG IEN", [val]) for val in ['O RX', 'I RX', 'UD RX', 'IV RX'] b.rpc('ORWU DT', ['NOW']) b.rpc('ORWCH LOADAL') Thanks, Steve Shreeve shreeve@s2s.org Aliso Viejo, CA