Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created July 5, 2022 18:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/119a52503f93dc146a5ea9c4d97c122c to your computer and use it in GitHub Desktop.
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
foo = :untouched
bar = :untouched
[:touched].each do |foo|
bar = :touched
end
foo #=> :untouched
bar #=> :touched
foo = :untouched
bar = :untouched
[:touched].each do |foo; bar|
bar = :touched
end
foo #=> :untouched
bar #=> :untouched
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