Skip to content

Commit

Permalink
tweak a sentence
Browse files Browse the repository at this point in the history
  • Loading branch information
knzai committed Jul 29, 2024
1 parent a71283f commit f2253ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/posts/ruby_enum_for.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
```
By returning an [Enumerator](https://ruby-doc.org/core-2.6/Enumerator.html) from your arbitrarily named (unlike implementing `Enumerable` via `#each`) traversal methods, you allow them to be chained as usual with `#map` (or any of the other similar methods). And you can then just call these methods directly from your `#each` implementation, making the enumerable methods work when called directly on an instance of the class (defaulting to depth).

Oh also make sure to deref/splat the children into your stack on breadth, so you don't mutate the children list directly. I didn't catch that till I added the tests to make sure you could repeat traversals safely. Which shows that tests are nice. Rust definitely would have made all this trickier... but in return would have caught that upfront.
Oh also make sure to deref/splat the children into your stack on breadth, so you don't mutate the children list directly. I didn't catch that till I added the tests to make sure you could repeat traversals safely. Which shows that tests are nice... but Rust would have caught that upfront (but also made this all quite a bit trickier. Tradeoffs).

In case it's of interest, here's the rest of the basic class:
```ruby
Expand Down

0 comments on commit f2253ce

Please sign in to comment.