Skip to content

Instantly share code, notes, and snippets.

@mhewedy
Created March 26, 2016 15:42
Show Gist options
  • Select an option

  • Save mhewedy/b088eff9dbf93ddcebe2 to your computer and use it in GitHub Desktop.

Select an option

Save mhewedy/b088eff9dbf93ddcebe2 to your computer and use it in GitHub Desktop.
val xs = List.fill(100)("X")
var count = 0
xs.maxBy { x =>
{
count += 1
x.length()
}
} //> res0: String = X
println(count) //> 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment