mirror of
https://github.com/jbranchaud/til
synced 2026-09-02 09:41:47 +00:00
Add link to Ruby docs and apply markdown formatting
This commit is contained in:
@@ -4,7 +4,9 @@ I recently ran into some code that was building up a hash keyed by _category_.
|
||||
It was a series of chained method calls building and transforming to produce the
|
||||
hash. It then ended with `.slice(*CATEGORIES)`.
|
||||
|
||||
That `#slice` call at the end was doing two things:
|
||||
That
|
||||
[`Hash#slice`](https://docs.ruby-lang.org/en/master/Hash.html#method-i-slice)
|
||||
call at the end was doing two things:
|
||||
|
||||
1. It was removing any key-value pairs not in `CATEGORIES`
|
||||
2. It was reordering the hash keys based on the order they appeared in `CATEGORIES`
|
||||
|
||||
Reference in New Issue
Block a user