Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1.  
  2. #Unless
  3.  
  4. Sometimes you want to use control flow to check if something is false, rather than if it's true. You could reverse your if/else, but Ruby will do you one better: it will let you use an unless statement.
  5.  
  6. Let's say you don't want to eat unless you're hungry. That is, while you're not hungry, you write programs, but if you are hungry, you eat. You might write that program in Ruby like this:
  7. ```
  8. unless hungry
  9. # Write some sweet programs
  10. else
  11. # Have some noms
  12. end
  13. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement