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
# Цикл от 2 до 20 с шагом 3 | |
for j in [2...20] by 3 | |
x = j * j | |
print x | |
# Цикл от 1 до n, где n — количество элементов в массиве | |
for k in [3, 5, 8, 13, 21] | |
x = k * k | |
print x | |
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
j = 0 | |
while j < 10 | |
j++ | |
print j | |
k = 0 | |
loop | |
k++ | |
print k | |
break if k > 10 |
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
for myColor in ["red", "green", "blue"] | |
print "my favorite color is #{myColor}, what's yours?” | |
# => my favorite color is red, what's yours? | |
# => my favorite color is green, what's yours? | |
# => my favorite color is blue, what's yours? |
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
# In conditional statements you can put the expression first | |
print "Game Over" if lives is 0 | |
# The inverse of "if" is aliased to "unless" | |
power = on unless lives is 0 | |
# Here's the English-language equivalents of logic operators !, &&, and ||: | |
drawGlow() if (not standing and energy > 10) or poweredUp | |
# The inverse form for simple expressions: |
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
# Можно ставить условие после выражения: | |
print "Game Over" if lives is 0 | |
# Для инверсии if есть отдельный оператор unless: | |
power = on unless lives is 0 | |
# Логические операторы "не", "и" и "или" можно писать словами: | |
if (not standing and energy > 10) or powered | |
print "Grow" |
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
for i in [1...10] | |
text = colour[i] | |
print text | |
if colour.length < 3 | |
print colour.length | |
circle.animate | |
properties: | |
x: 640 |
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
var colour = ["red", "green", "blue"]; | |
for (var i = 0; i < 10; i++) { | |
var text = colour[i]; print(text); | |
} if (colour.length < 3) { | |
print(colour.length); | |
} | |
var circle = new Layer { | |
x: 320; y: 240; borderRadius: 50; | |
} |
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
5 + 13 |
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
x = 5 + 13 | |
y = 5 + 13 | |
width = 100 | |
height= width * 2 |
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
// JavaScript | |
var x, y, width, height; | |
x = 5 + 13; | |
y = 5 + 13; | |
width = 100; | |
height = width * 2; |