Link to home
Start Free TrialLog in
Avatar of Mark_Co
Mark_CoFlag for United States of America

asked on

next if and next unless vs if and unless in Ruby

What are the benefits of next if and next unless vs if and unless in Ruby?

Here are two examples I am referring to.

 next if file == '.' || file == '..'				
      next unless file.end_with?('.rb') || file.end_with?('.erb')

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark_Co

ASKER

so this line next if file == '.' || file == '..' basically says "move on and ignore this current iteration if you run into a . or a .. " ?
Yes that's correct.