Crystal notes



(0..10).step(2) do |x|
    puts x
end

---

x = ["the","end","game"]
x[0..1].each() do |y|
    puts y
end

---

# times method
2.times do |n|
    puts n
end

---

# upto method
0.upto(1) do |n|
    puts n
end

---

For ranges it's simple: x..y defines a range from x to y inclusive
and x...y defines a range from x to y exclusive. So if you want the
same behavior as times use 0...n. For x.upto(y) there is only one version which will iterate upto and including y.

Popular posts from this blog

Create a new repo

Fixing DNS Resolution problems with Linux Mint 19