4-2-ranges.coffee 297 B

123456789101112131415161718
  1. bot = 3
  2. top = 0
  3. # With right limit
  4. range1 = [bot..top]
  5. # Without right limit
  6. range2 = [bot...top]
  7. console.log range1, range2
  8. # Referencing ranges
  9. start = 5
  10. end = 10
  11. range3 = [start..end]
  12. console.log range3[1..3]
  13. console.log range3[1..range3.length]
  14. # Negative indexes
  15. console.log range3[1..-2]