Skip to content

Instantly share code, notes, and snippets.

@yuyosy
Created September 25, 2018 13:40
Show Gist options
  • Save yuyosy/30c410f0f0c145d2dca1dcdb8ba5a536 to your computer and use it in GitHub Desktop.
Save yuyosy/30c410f0f0c145d2dca1dcdb8ba5a536 to your computer and use it in GitHub Desktop.
Julia <if-else>
x = 2
y = 5
# プログラムでの一般的なの書き方
println(0<x && x<3) # true
println(0<x && x<1) # false
# 数学的な書き方(`&&` の省略)
println(0<x<3) # true
println(0<x<1) # false
println(0<x<3<y) #true # 複数変数を含めての評価も可能
if 0 < x
println("x is greater than 0")
elseif x < 0
println("x is less than 0")
else
println("x is 0")
end
# ifelse関数
println(ifelse(0<x<3, "x is 0<x<3", "x is not 0<x<3"))
# 三項演算
println(0<x<3 ? "x is 0<x<3" : "x is not 0<x<3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment