next versus if in a .each loop?
问题 I have a text processing thing I'm doing in Ruby. Basically, I have to implement a simple state machine (with one character look-behind). My code at the moment looks like this: text.each{ |c| ... ... ... ... if @state!=:some_state next end #processing stuff for if in :some_state mode ... ... ... ... ... } Is this proper? Or should it rather be implemented like: text.each{ |c| ... ... ... ... if @state==:some_state #processing stuff for if in :some_state mode ... ... ... ... ... end } Is there