Skip to content

Instantly share code, notes, and snippets.

View antonkartashov's full-sized avatar

Anton Kartashov antonkartashov

  • Orenburg, Russia
View GitHub Profile
# Цикл от 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
j = 0
while j < 10
j++
print j
k = 0
loop
k++
print k
break if k > 10
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?
# 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:
# Можно ставить условие после выражения:
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"
for i in [1...10]
text = colour[i]
print text
if colour.length < 3
print colour.length
circle.animate
properties:
x: 640
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;
}
x = 5 + 13
y = 5 + 13
width = 100
height= width * 2
// JavaScript
var x, y, width, height;
x = 5 + 13;
y = 5 + 13;
width = 100;
height = width * 2;