Guest User

Untitled

a guest
Jan 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. if (myList.isEmpty) return x > 5
  2. if x < 0 return false
  3. if (myList.head == "+") return foo()
  4. if (myList.head == "-") return bar()
  5.  
  6. if(x > 0) {
  7. myList.headOption match {
  8. case Some("+") => foo()
  9. case Some("-") => bar()
  10. case None => x > 5
  11. } else false
  12.  
  13. myList match {
  14. case Nil => x > 5
  15. case _ if x < 0 => false
  16. case "+" :: _ => foo()
  17. case "-" :: _ => bar()
  18. }
  19.  
  20. def sampleFunction: Boolean =
  21. lst match {
  22. case Nil => x > 5
  23. case _ if (x < 0) => false
  24. case "+" :: _ => true
  25. case "-" :: _ => false
  26. case _ => true // return something if nothing matches
  27. }
Add Comment
Please, Sign In to add comment