Implement if-to-when and when-to-if transformations

This commit is contained in:
Alexey Sedunov
2013-04-26 14:10:00 +04:00
parent c054c0cdbe
commit 3c691062ad
9 changed files with 340 additions and 0 deletions
@@ -0,0 +1,11 @@
when (n) {
1 -> {
res = "one"
}
2 -> {
res = "two"
}
else -> {
res = "???"
}
}
@@ -0,0 +1,7 @@
if (n == 1) {
res = "one"
} else if (n == 2) {
res = "two"
} else {
res = "???"
}
@@ -0,0 +1,5 @@
<html>
<body>
This intention converts 'if' expression to equivalent 'when' expression
</body>
</html>