dealingwith

fif

Jan 26th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function print_true()
  2. print("true")
  3. end
  4.  
  5. function print_false()
  6. print("false")
  7. end
  8.  
  9. function fif(val, a, b)
  10. if val then a() else b() end
  11. end
  12.  
  13. function fif_flip(val, a, b)
  14. if val then a() else b() end
  15. return not val
  16. end
  17.  
  18. fif(true, print_true, print_false) -- prints "true"
  19. fif_flip(false, print_true, print_false) -- prints "false", returns true
Advertisement
Add Comment
Please, Sign In to add comment