Skip to content

Instantly share code, notes, and snippets.

@kyuden
Created June 15, 2014 08:25
Show Gist options
  • Save kyuden/ebe8ebb45b9db8b3d63d to your computer and use it in GitHub Desktop.
Save kyuden/ebe8ebb45b9db8b3d63d to your computer and use it in GitHub Desktop.
# 02
message = "hello"
if message.length > 1
alert message
# 03
s = "hello
safdaf
asdf
asfdfda"
s = """
here
document
enable
"""
name = "taguchi"
alert "hi, #{name}#{15/3}"
#04
a0 = [1, 2, 3, 4]
a1 = [
1, 2, 3
2, 4, 2
]
a2 = {"sato": 100, "sasaki": 200}
a3 =
"sato": 100
"sasaki": 300
"sum":
"sales": 399
"area": 400
#05
signal = "red"
if signal == "red"
alert "stop"
else if singal == "green"
alert "ok"
else
alert "caution"
#06
x = 30
alert "ok" if 10 < x < 40
#07
# switch
signal = "green"
switch signal
when "red"
alert "stop"
when "green"
alert "go"
else
alert "caution"
# 08
# 定義済 and 空でない
alert "ok" if name?
#09
for i in [0..3]
alert i
a = ["tanaka", "taguchi", "sasaki"]
for i, index in a
alert "hi, #{index}:#{i}"
#10
sales =
"tanaka": 100
"taguchi": 200
"sasaki": 300
for key, value of sales
alert "#{key}:#{value}"
#11
hello = (name="tarou") ->
alert "#{name}hello"
hello()
#12
sum = (a, b) ->
a + b
alert sum(1, 2)
#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment