Created
July 5, 2022 18:44
-
-
Save havenwood/119a52503f93dc146a5ea9c4d97c122c to your computer and use it in GitHub Desktop.
An example of why we use `each` rather than `for` and what semicolon block args do for #ruby IRC
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
foo = :untouched | |
bar = :untouched | |
[:touched].each do |foo| | |
bar = :touched | |
end | |
foo #=> :untouched | |
bar #=> :touched |
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
foo = :untouched | |
bar = :untouched | |
[:touched].each do |foo; bar| | |
bar = :touched | |
end | |
foo #=> :untouched | |
bar #=> :untouched |
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
foo = :untouched | |
bar = :untouched | |
for foo in [:touched] | |
bar = :touched | |
end | |
foo #=> :touched | |
bar #=> :touched |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment