Skip to content

Instantly share code, notes, and snippets.

@ceptreee
Created March 14, 2020 03:11
Show Gist options
  • Save ceptreee/529fa1e2e612df5e65d1122a26fc3631 to your computer and use it in GitHub Desktop.
Save ceptreee/529fa1e2e612df5e65d1122a26fc3631 to your computer and use it in GitHub Desktop.
function hoge(number)
if number == 1
f() = "1"
elseif number == 2
f() = "2"
end
return f
end
f = hoge(1)
println(f()) # 2
hoge(2) # ERROR: UndefVarError: f not defined
function hoge(number)
if number == 1
f() = 1
x = 1
elseif number == 2
f() = 2
x = 2
end
return f,x
end
f,x = hoge(1)
println(f()) # 2
println(x) # 1
hoge(2) # ERROR: UndefVarError: f not defined
function hoge(number)
if number == 1
f() = 1
println(1)
elseif number == 2
f() = 2
println(2)
end
return f
end
f = hoge(1) # 1
println(f()) # 2
f = hoge(2) # 2
# # ERROR: UndefVarError: f not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment