scala - Filtering a list of tuples -
i have list of tuples , want filter out elements second value in tuple not equal 7.
i do:
valuesaslist.filter(x=>x._2 != 7)
can use wildcard notation make shorter?
thanks.
you can
valuesaslist.filter(_._2 != 7)
but doubt should preferred on example or (think readability):
valuesaslist.filter {case (_, v) => v != 7}
Comments
Post a Comment