Created
March 14, 2020 03:11
-
-
Save ceptreee/529fa1e2e612df5e65d1122a26fc3631 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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