Last active
January 2, 2016 00:59
-
-
Save paulp/8227277 to your computer and use it in GitHub Desktop.
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> def drop[T](xs: List[T], n: Int) = if (xs.isEmpty || n <= 0) xs else drop(xs.tail, n - 1) | |
drop: [T](xs: List[T], n: Int)List[T] | |
scala> drop(List(1,2,3,4,5), 3) | |
res0: List[Int] = List(4, 5) |
scala> def h() = if (true) h() else 123
h: ()Int
Or to the limit:
scala> def h() = if (true) h() else h()
h: ()Nothing
scala> def rand = scala.util.Random.nextBoolean
rand: Boolean
scala> def f[A <: String, B <: String](x: A, y: B) = (
| if (rand) f(x, y)
| else if (rand) f(y, y)
| else x -> y
| )
f: [A <: String, B <: String](x: A, y: B)(String, B)
So... who do I have to kill to get this into scala/master ?
I'm no longer in the scalac game. If someone wants to try to dredge it from my inevitable fork they will be welcome.
For this to happen you should upload your branches to github.
I'm aware of the prerequisite.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happens to the inferred type of h if you define it as "def h() = if (true) h() else 123"?