sapphire-lang 0.7.0

Gradually typed scripting language where every value is an object and types are optional, checked at runtime
Documentation
# control_flow.spr — if/elsif/else, while, break, next

# if / elsif / else
def grade(score: Int) -> String {
  if score >= 90 {
    "A"
  } elsif score >= 80 {
    "B"
  } elsif score >= 70 {
    "C"
  } else {
    "F"
  }
}

print grade(95)
print grade(83)
print grade(71)
print grade(50)

# while — sum 1 to 100
sum = 0
n = 1
while n <= 100 {
  sum = sum + n
  n = n + 1
}
print "Sum 1..100 = #{sum}"

# while with next (skip) and break (exit early)
# increment first so next doesn't cause an infinite loop
i = 0
while i < 10 {
  i = i + 1
  next if i % 2 == 0   # skip even numbers
  break if i > 7       # stop after 7
  print i
}
# prints 1, 3, 5, 7