Provides over 200 coercions between types. This works for the following matrix of types:
TO
Bo C By Sh I L F D JBy JSh JI JL JF JD JC JBo St
+--------------------------------------------------------------------
Bo | I bB tS
C | I A A A A A A A A A A A A A tS
By | A I A A A A A A A A A A A A tS
Sh | A A I A A A A A A A A A A A tS
I | A A A I A A A A A A A A A A tS
L | A A A A I A A A A A A A A A tS
F F | A A A A A I A A A A A A A A tS
R D | A A A A A A I A A A A A A A tS
O JBy | N N N N N N N I N N N N N N tS
M JSh | N N N N N N N N I N N N N N tS
JI | N N N N N N N N N I N N N N tS
JL | N N N N N N N N N N I N N N tS
JF | N N N N N N N N N N N I N N tS
JD | N N N N N N N N N N N N I N tS
JC | uC I tS
JBo | uB I tS
St | I
Where the label abbreviations are:
Bo: scala.Boolean
C: scala.Char
By: scala.Byte
Sh: scala.Short
I: scala.Int
L: scala.Long
F: scala.Float
D: scala.Double
JBy: java.lang.Byte
JSh: java.lang.Short
JI: java.lang.Integer
JL: java.lang.Long
JF: java.lang.Float
JD: java.lang.Character
JC: java.lang.Double
JBo: java.lang.Boolean
St: java.lang.String
and value abbreviations are:
A: coercion from scala.AnyVal
N: coercion from java.lang.Number
I: identity function
bB: boxing Boolean coercion
uB: unboxing Boolean coercion
uC: unboxing character coercion
tS: toString coercion
The rationale behind not supplying coercion from Strings is that too many exceptions can
be thrown during the coercion process. Coercions from String to character have issues
with the empty string. One could call one of the following but they all throw exceptions:
"".charAt(0) // java.lang.StringIndexOutOfBoundsException: String index out of range: 0"".apply(0) // java.lang.StringIndexOutOfBoundsException: String index out of range: 0"".head // java.util.NoSuchElementException: next on empty iterator
Conversion to Boolean from Numbers and vice versa is not supported because there are a
number of ways to do this:
Provides over 200 coercions between types. This works for the following matrix of types:
Where the label abbreviations are:
and value abbreviations are:
The rationale behind not supplying coercion from Strings is that too many exceptions can be thrown during the coercion process. Coercions from String to character have issues with the empty string. One could call one of the following but they all throw exceptions:
Conversion to Boolean from Numbers and vice versa is not supported because there are a number of ways to do this: