Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View chooyan-eng's full-sized avatar

Chooyan chooyan-eng

View GitHub Profile
# 「子供」を表現するコード
class Child
# おつかいに行くためには、商品とお店の情報が必要
def go_shopping(item, shop)
walk_to(shop) # お店に行く
buy(item) # 商品を買う
come_back(@home) # 家に帰ってくる
child = Child.new # 子供に対して
child.go_shopping("牛乳", "スーパー") # 商品情報(牛乳)とお店の情報(スーパー)を与えておつかいに行くよう指示する。
# 「子供」を表現するコード
class Child
# 商品の情報があればおつかいに行ける
def go_shopping(item)
shop = lookup(item) # 自分の記憶から、商品がどこで売っているかを考える
walk_to(shop) # お店に行く
@chooyan-eng
chooyan-eng / var_test.dart
Created March 12, 2019 14:23
Test that var can be used at arguments of functions in Dart.
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);
}
void main() {
var val = 10;
print(val);
val = "str"; // reassign value here is invalid
print(val);
}
void main() {
printArg(10);
}
printArg(var arg) {
print(arg); // -> 10
arg = "str"; // reassigning here is valid
print(arg); // -> str
}
void main() {
var date = "2019/03/13";
print("It is $date today."); // -> It is 2019/03/13 today.
}
void main() {
var nums1 = [1, 2, 3];
nums1[1] = 99; // valid
print(nums1[1]);
const nums2 = [1, 2, 3];
nums2[1] = 99; // invalid: runtime error
print(nums2[1]);
var nums3 = const [1, 2, 3];
void main() {
var clazz = MyClass();
clazz..printNum() // -> 1
..increment(1)
..printNum(); // -> 2
}
class MyClass {
var num = 1;
@chooyan-eng
chooyan-eng / flutter_creater.sh
Last active December 10, 2021 05:43
Shell script for create Flutter sample project of given Widget
#!/bin/bash
if [ $# -ne 1 ]; then
echo "USAGE: a single Widget name must be given as an argument. See example below" 1>&2
echo "USAGE: sh flutter_creater.sh InkWell" 1>&2
exit 1
fi
WIDGET_NAME=$1
WIDGET_NAME_LOWER=`echo ${WIDGET_NAME} | tr '[:upper:]' '[:lower:]'`