Can someone exaplain me implicit parameters in Scala?
- by Oscar Reyes
And more specifically how does the BigInt works for convert int to BigInt?
In the source code it reads:
...
implicit def int2bigInt(i: Int): BigInt = apply(i)
...
How is this code invoked?
I can understand how this other sample: "Date literals" works.
In.
val christmas = 24 Dec 2010
Defined by:
implicit def dateLiterals(date: Int) = new {
import java.util.Date
def Dec(year: Int) = new Date(year, 11, date)
}
When int get's passed the message Dec with an int as parameter, the system looks for another method that can handle the request, in this case Dec(year:Int)
Q1. Am I right in my understanding of Date literals?
Q2. How does it apply to BigInt?
Thanks