versioninfo() function func1(x) sin(x) # return が無くても最後の式が返値になる end func1(x) = sin(x) # 同じシグネチャで再定義すると上書き可能 func2 = x -> sin(x) func2 = func1 func2 = 1 func1 = x -> sin(x) const func3 = x -> sin(x) func2 = func3 println(x->x) x->x function test(a, other... ; opt1=0, options...) println("a=", a, ", other=", other) println("opt1=", opt1, ", options=", options) end test(1, 2, 3, 4; opt1=1, opt2=2, opt3=3) test((1,2,3)...) test([1,2,3]...) test([1,2]...) length((1,)) test(1;[(:opt1, 1), (:opt2, 2)]...) test2(a::Int) = println("Int") test2(s::String) = println("String") test2(1) test2("a") test2(a::Number) = println("Number") test2(1.0) test2(1) test2(a) = println("Any type") test2(true) test2([]) test2(1.0) test2(1) test2(a...) = println("Variable args of any type") test2(1) test2([]) test2(a::Array...) = print("Variable args of Array") test2([]) test2(:symbol) test2(a, b=false) = println("With omittable b") test2(1) test2(:symbol) test3(a) = println("Any type") test3(a; option=false) = println("Any type with option") test3(1) test3(a) = println("Any type") test3(1) test3(1, option=true) test3(a; option2=false) = println("Any type with option2") test3(1, option=true) test3(1, option2=true) test3(a; options...) = println("Any type with options") test3(1, option2=true) test3(a; option2=false) = println("Any type with option2") test3(1, option2=true) test3(1, option1=true) test4(a) = "only a" test4(a, b=false) = "with omittable b" test4("which should be called?") test4(a) = "only a" test4("which should be called?") test4(1, 2)