Last active
August 13, 2017 13:44
-
-
Save tototoshi/a67b5a38be3f7de846628f5e28b58287 to your computer and use it in GitHub Desktop.
SortedSet#map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import scala.collection.immutable.SortedSet | |
import scala.collection.immutable.SortedSet | |
scala> case class Hoge(i: Int) | |
defined class Hoge | |
scala> SortedSet(1, 2, 3, 4, 5) | |
res0: scala.collection.immutable.SortedSet[Int] = TreeSet(1, 2, 3, 4, 5) | |
scala> SortedSet(1, 2, 3, 4, 5).map(Hoge.apply) | |
res1: scala.collection.immutable.Set[Hoge] = Set(Hoge(4), Hoge(1), Hoge(3), Hoge(5), Hoge(2)) | |
scala> SortedSet(1, 2, 3, 4, 5).map(1+) | |
warning: there was one feature warning; re-run with -feature for details | |
res2: scala.collection.immutable.SortedSet[Int] = TreeSet(2, 3, 4, 5, 6) | |
scala> implicit val o: Ordering[Hoge] = Ordering.by(h => h.i) | |
o: Ordering[Hoge] = scala.math.Ordering$$anon$9@e27ba81 | |
scala> SortedSet(1, 2, 3, 4, 5).map(Hoge.apply) | |
res3: scala.collection.immutable.SortedSet[Hoge] = TreeSet(Hoge(1), Hoge(2), Hoge(3), Hoge(4), Hoge(5)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
scala/scala#6037