else_if.ion 602 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Single Else If Condition
  2. if test 1 -gt 5
  3. echo one
  4. else if test 1 -eq 1
  5. echo two
  6. else
  7. echo three
  8. end
  9. # Multiple Else Conditions
  10. let a = 4
  11. if test $a -eq 1
  12. echo one
  13. else if test $a -eq 2
  14. echo two
  15. else if test $a -eq 3
  16. echo three
  17. else if test $a -eq 4
  18. echo four
  19. else
  20. echo five
  21. end
  22. # Nested Else If Conditions
  23. let a = 5
  24. let b = 10
  25. if test $a -gt 10
  26. echo "a > 10"
  27. else if test $a -lt 10
  28. echo "a < 10"
  29. if test $a -gt $b
  30. echo "a > b"
  31. else if test $a -eq $b
  32. echo "a == b"
  33. else
  34. echo "a < b"
  35. end
  36. else
  37. echo "a == 10"
  38. end