This file contains hidden or 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
void main() { | |
printArg(10); | |
} | |
printArg(var arg) { | |
print(arg); // -> 10 | |
arg = "str"; // reassigning here is valid | |
print(arg); // -> str | |
} |
This file contains hidden or 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
void main() { | |
var val = 10; | |
print(val); | |
val = "str"; // reassign value here is invalid | |
print(val); | |
} |
This file contains hidden or 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
void main() { | |
printArg(10); // -> 10 | |
printArg("10"); // -> 10 | |
printArg([10, 20, 30]); // -> [10, 20, 30] | |
printArg({10, 20, 30}); // -> {10, 20, 30} | |
} | |
printArg(var arg) { | |
print(arg); | |
} |
This file contains hidden or 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
# 「子供」を表現するコード | |
class Child | |
# 商品の情報があればおつかいに行ける | |
def go_shopping(item) | |
shop = lookup(item) # 自分の記憶から、商品がどこで売っているかを考える | |
walk_to(shop) # お店に行く |
This file contains hidden or 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
child = Child.new # 子供に対して | |
child.go_shopping("牛乳", "スーパー") # 商品情報(牛乳)とお店の情報(スーパー)を与えておつかいに行くよう指示する。 |
This file contains hidden or 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
# 「子供」を表現するコード | |
class Child | |
# おつかいに行くためには、商品とお店の情報が必要 | |
def go_shopping(item, shop) | |
walk_to(shop) # お店に行く | |
buy(item) # 商品を買う | |
come_back(@home) # 家に帰ってくる |
NewerOlder