Created
January 19, 2019 04:12
-
-
Save diskshima/d0b2a54735b2924a9168195f658b3d09 to your computer and use it in GitHub Desktop.
Ruby version of an Index error case (https://ericlippert.com/2019/01/18/indexer-error-cases/)
This file contains 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
# A Ruby implementation to confirm when assignments happen. | |
# Inspired by https://ericlippert.com/2019/01/18/indexer-error-cases/ | |
# Prints | |
# A | |
# B | |
# C | |
# catch | |
def a | |
puts 'A' | |
[] | |
end | |
def b | |
puts 'B' | |
'aaaaa' | |
end | |
def c | |
puts 'C' | |
123 | |
end | |
begin | |
a()[b()] = c | |
rescue | |
puts 'catch' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment