Created
April 16, 2016 10:18
-
-
Save xianminx/3a0be0e6f607964728d3272f07504eac to your computer and use it in GitHub Desktop.
scala implicit conversions
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
public final class App$ | |
{ | |
public static final MODULE$; | |
private final int someInt; | |
static | |
{ | |
new (); | |
} | |
public int double2Int(double d) | |
{ | |
return (int)d; | |
} | |
public int someInt() | |
{ | |
return this.someInt; | |
} | |
private App$() | |
{ | |
MODULE$ = this;this.someInt = double2Int(2.3D); | |
} | |
} |
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
import scala.reflect.ScalaSignature; | |
@ScalaSignature(bytes="\006\001\r:Q!\001\002\t\002\025\t1!\0219q\025\005\031\021a\002\037f[B$\030PP\002\001!\t1q!D\001\003\r\025A!\001#\001\n\005\r\t\005\017]\n\003\017)\001\"a\003\b\016\0031Q\021!D\001\006g\016\fG.Y\005\003\0371\021a!\0218z%\0264\007\"B\t\b\t\003\021\022A\002\037j]&$h\bF\001\006\021\025!r\001b\001\026\003)!w.\0362mKJJe\016\036\013\003-e\001\"aC\f\n\005aa!aA%oi\")!d\005a\0017\005\tA\r\005\002\f9%\021Q\004\004\002\007\t>,(\r\\3\t\017}9!\031!C\001A\00591o\\7f\023:$X#\001\f\t\r\t:\001\025!\003\027\003!\031x.\\3J]R\004\003") | |
public final class App | |
{ | |
public static int someInt() | |
{ | |
return App..MODULE$.someInt(); | |
} | |
public static int double2Int(double paramDouble) | |
{ | |
return App..MODULE$.double2Int(paramDouble); | |
} | |
} |
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
object App{ | |
implicit def double2Int(d:Double):Int = d.toInt | |
// the compiler compiles to : MODULE$ = this;this.someInt = double2Int(2.3D); | |
val someInt:Int = 2.3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment