Skip to content

Instantly share code, notes, and snippets.

@furquanuddin94
Last active November 25, 2020 10:17
Show Gist options
  • Save furquanuddin94/3d7cd80bfe7bf81b51458aec01061c2d to your computer and use it in GitHub Desktop.
Save furquanuddin94/3d7cd80bfe7bf81b51458aec01061c2d to your computer and use it in GitHub Desktop.
//list of integers
val myList: List[Int] = List(1,2,7,3)
//function to multiply an integer by 2
def doubleUpFunction: Int => Int = value => value*2
//creating a new list multiplying each element by 2
myList.map(element => doubleUpFunction(element)) //output: List(2, 4, 14, 6)
//or simply
myList.map(doubleUpFunction) //output: List(2, 4, 14, 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment