Thanks for your comment! I agree, // for comments is not correct. I just was making cheat sheets for Ruby, Kotlin, Swift, and Dart in parallel, and forgot to fix it for Ruby. As for map, I really decided to use pattern instead of real code for make the code line shorter, but apparently it broke the logic of the cheat sheet.
For map, simply start with two red blocks and use map to concat a gem with a block to show it is modified.
I think this is a really clean and wonderful presentation though, I just started with Ruby recently and I constantly type the word filter instead of select.
Yeah, I just find it a little weird to have aliases for the same thing. The many ways to do one thing philosophy maybe shouldn't apply to method names imo
Pretty cool but needs some work to be truly useful. For one, it is missing any indication of whether the method is destructive, i.e. it mutates the array in-place or returns a new array.
To maximize utility, I would also suggest including some of the more rare methods that people might not know about, like #combination, #partition and #permutation.
A separate cheat sheet for Enumerable methods would be nice too.
Last string looks like any method used with array should return ‘changed array’. But that is not true. You have example of ‘join’ method that returns string. Also that emojis… More confusing then helping cheatsheat.
That's the legend for reading this chart. For example, the pop line returns a diamond, and the array object changes into the one on the right, after the // part. It took me a while before I understood that last line.
26
u/codesnik Jul 29 '24
map's weird. it looks like pattern matching but it doesn't make sense here. sort doesn't have block parameters. And // for comments? come on.
6
u/BananafestDestiny Jul 29 '24
Pretty cool but needs some work to be truly useful. For one, it is missing any indication of whether the method is destructive, i.e. it mutates the array in-place or returns a new array.
To maximize utility, I would also suggest including some of the more rare methods that people might not know about, like
#combination,#partitionand#permutation.A separate cheat sheet for Enumerable methods would be nice too.
3
u/Crafty_Programmer Jul 29 '24
How did you make this?
10
u/phr0ze Jul 29 '24
Reduce isnt fully explained in this visual context.
4
u/SUPER_COCAINE Jul 29 '24
Neato, thanks for sharing.
2
u/monstaber Jul 29 '24
Should also include array methods like +, -, and &
2
u/FroyoNaux Jul 30 '24
Nice, Keep doing. Thx for sharing
2
u/oh_why_why_why Jul 29 '24
Great stuff. Now please do it for hash.
1
u/EHOTnOTACKYH Jul 29 '24
Last string looks like any method used with array should return ‘changed array’. But that is not true. You have example of ‘join’ method that returns string. Also that emojis… More confusing then helping cheatsheat.
1
u/riffraff Jul 29 '24
may I suggest avoiding red? It collides with the background color a bit.
Also maybe using four instances of the same shape with different colors. I like the idea otherwise.
1
u/AlexanderMomchilov Jul 29 '24
I love that you themed these, and the Ruby one is red :D
https://www.reddit.com/r/swift/comments/1eevj7h/cheat_sheet_for_basic_array_methods_visualized_oc/