Skip to content

Instantly share code, notes, and snippets.

@mzimecki
Last active December 19, 2015 19:48
Show Gist options
  • Save mzimecki/6008387 to your computer and use it in GitHub Desktop.
Save mzimecki/6008387 to your computer and use it in GitHub Desktop.
[Scala] Many ways of passing x < 0 function into exists function (verbose version as first one). Each of them has the same meaning.
def containsNeg1(nums: List[Int]) = nums.exists((x: Int) => x < 0)
def containsNeg2(nums: List[Int]) = nums.exists((x) => x < 0)
def containsNeg3(nums: List[Int]) = nums.exists(x => x < 0)
def containsNeg4(nums: List[Int]) = nums.exists(_ < 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment