Last active
December 20, 2015 05:29
-
-
Save suzuki0keiichi/6078606 to your computer and use it in GitHub Desktop.
Scala.jsでifの最後の評価結果の代入がどのように変換されるか
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
ScalaJS.c.helloworld\ufe33HelloWorld$.prototype.hoge\ufe34I\ufe34O = (function(arg$num) { | |
// 宣言時の場合は評価結果の場で宣言される(Javascriptではifブロック内スコープは無いので) | |
if ((arg$num === 20)) { | |
var value$jsid$11972 = "hello" | |
} else { | |
var value$jsid$11972 = "bye" | |
}; | |
// 再代入の場合は評価結果の場で代入される | |
if ((arg$num === 20)) { | |
value$jsid$11972 = "hello" | |
} else { | |
value$jsid$11972 = ScalaJS.bI(10) | |
}; | |
// 戻り値も評価結果の場にreturnが入る | |
return value$jsid$11972 | |
}); |
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
ScalaJS.c.HelloWorld$.prototype.hoge__I__O = (function(num) { | |
// 宣言時の場合は評価結果の場で宣言される(Javascriptではifブロック内スコープは無いので) | |
if ((num === 20)) { | |
var value = "hello" | |
} else { | |
var value = "bye" | |
}; | |
if ((num === 20)) { | |
value = "hello" | |
} else { | |
value = ScalaJS.bI(10) | |
}; | |
return value | |
}); |
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 HelloWorld { | |
def hoge(num: Int) = { | |
var value: Any = if (num == 20) { "hello" } else { "bye" } | |
value = if (num == 20) { "hello" } else { 10 } | |
value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment