Last active
December 11, 2015 19:28
-
-
Save vkgtaro/4648283 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
| my $outer = "outer"; | |
| if (1) { | |
| print $outer . "\n"; | |
| my $inner = "inner"; | |
| } | |
| print $inner . "\n"; | |
| __END__ | |
| outer |
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
| outer = "outer" | |
| if True: | |
| print outer | |
| inner = "inner" | |
| print inner | |
| """ | |
| outer | |
| inner | |
| """ |
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
| outer = "outer" | |
| if true | |
| puts outer | |
| inner = "inner" | |
| end | |
| puts inner | |
| # outer | |
| # inner |
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
| my $outer = "outer"; | |
| sub func { | |
| print $outer . "\n"; | |
| my $inner = "inner"; | |
| } | |
| func(); | |
| print $inner . "\n"; | |
| __END__ | |
| outer | |
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
| outer = "outer" | |
| def func(): | |
| print outer | |
| inner = "inner" | |
| func() | |
| print inner | |
| """ | |
| outer | |
| Traceback (most recent call last): | |
| File "func.py", line 8, in <module> | |
| print inner | |
| NameError: name 'inner' is 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
| outer = "outer" | |
| def func() | |
| puts outer # <= undefined local variable or method `outer' for main:Object (NameError) | |
| inner = "inner" | |
| end | |
| func() | |
| puts inner # <= undefined local variable or method `inner' for main:Object (NameError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment