New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameters should be allowed as by-name and repeated #237
Comments
Imported From: https://issues.scala-lang.org/browse/SI-237?orig=1 |
@odersky said: |
DaveScala (davescala) said (edited on Jun 30, 2012 5:38:39 PM UTC): http://www.scala-lang.org/node/4272 In constructor: |
@jrudolph said: |
@retronym said: |
@paulp said: |
@dcsobral said: class SeqFunction0[T](xs: Seq[T]) extends Seq[T] with EverythingThatItEntails[T, SeqFunction0[T]] {
override def apply(n: Int): T = xs(n).apply()
// any other required overrides
} I think that most closely mirrors the behavior I would expect: def f(xs: => Int*): Int = {
for (i <- xs.indices) {
val current = xs(i) // so it won't evaluate twice below
if (xs(i) % 2 == 1) return xs(i)
}
0
}
println(f(0, {println("Printed once!"); 2}, 4, 1, ???)) // prints "Printed once!" then "1" Note: the braces are playing hell with formatting in the first line. I had to opt between no formatting and extraneous { and }, and I opted for the latter. |
@paulp said: |
@SethTisue said: |
I don't know what it means, but rejected and withdrawn SIPs are accessible as PRs. scala/improvement-proposals#23
|
"Backports welcome." |
Compiling
should be allowed.
The text was updated successfully, but these errors were encountered: