Skip to content

Instantly share code, notes, and snippets.

@miyakogi
Last active July 22, 2024 04:42
Show Gist options
  • Save miyakogi/7037bb1ad19c35d4a483 to your computer and use it in GitHub Desktop.
Save miyakogi/7037bb1ad19c35d4a483 to your computer and use it in GitHub Desktop.
FizzBuzz-mod
# これはコメント
const f: string = "Fizz" # 定数(変更不可)
var b = "buzz" # 変数(変更可) 型指定は必須ではない
b = "Buzz" # 変数の値を変更
for i in 1..100: # 1から100までforループ
if i mod 15 == 0: # == で比較
echo(f & b) # 文字列連結(&) して標準出力へ
elif i mod 5 == 0: # else if な時はPython同様elif
echo b # echoは括弧なしでもOK
elif i mod 3 == 0:
f.echo() # これはecho(f)と同じ。メソッドチックな書き方
else:
i.echo # 引数が一つの時は、空の()を省略できる
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment