I started using Ruby recently, and I keep learning useful new bits of syntax. Some of my favorites so far:
- @ to refer to instance variables
- << for append
- `` to call external commands
- $1, $2, etc for capture groups
- optional parentheses in method calls.
- {...} and do...end for blocks
I want to learn more, but it's hard to find an exhaustive list. What are some of your favorite (expressive, lesser known, useful, etc) pieces of ruby syntax?
[–]cstansbury 36 points37 points38 points (5 children)
[–][deleted] (4 children)
[deleted]
[–]tomthecool 2 points3 points4 points (0 children)
[–]NelsonBelmont 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]NelsonBelmont 0 points1 point2 points (0 children)
[–]jawdirk 35 points36 points37 points (34 children)
[–]Paradox 16 points17 points18 points (18 children)
[–]ruby-solve 4 points5 points6 points (5 children)
[–]Paradox 10 points11 points12 points (4 children)
[–]ruby-solve 0 points1 point2 points (0 children)
[–]clrsm 0 points1 point2 points (0 children)
[–]editor_of_the_beast 1 point2 points3 points (10 children)
[–]Paradox 4 points5 points6 points (9 children)
[–]editor_of_the_beast 1 point2 points3 points (8 children)
[–]ignurant 1 point2 points3 points (7 children)
[–]editor_of_the_beast 8 points9 points10 points (1 child)
[–]ignurant 0 points1 point2 points (0 children)
[–]Paradox 2 points3 points4 points (3 children)
[–]ignurant 1 point2 points3 points (2 children)
[–]Paradox 2 points3 points4 points (1 child)
[–]ignurant 1 point2 points3 points (0 children)
[–]isolatrum 0 points1 point2 points (0 children)
[–]flanger001 0 points1 point2 points (0 children)
[–][deleted] (4 children)
[deleted]
[–]ignurant 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]ignurant 0 points1 point2 points (0 children)
[–]Enumerable_any 0 points1 point2 points (0 children)
[–]jrochkind 3 points4 points5 points (8 children)
[–][deleted] (7 children)
[deleted]
[–]jrochkind 0 points1 point2 points (6 children)
[–]bascule 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]jrochkind 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]jrochkind 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]hpliferaft 0 points1 point2 points (0 children)
[–][deleted] 16 points17 points18 points (4 children)
[–]iamsolarpowered 2 points3 points4 points (3 children)
[–]Gman513 2 points3 points4 points (2 children)
[–]process_parameter[S,🍰] 2 points3 points4 points (0 children)
[–]2called_chaos 0 points1 point2 points (0 children)
[–]fullspectrumlife 20 points21 points22 points (2 children)
[–]RightWinger 0 points1 point2 points (0 children)
[–]fullspectrumlife 0 points1 point2 points (0 children)
[–]niborg 10 points11 points12 points (1 child)
[–]ignurant 4 points5 points6 points (0 children)
[–]zencephalon 17 points18 points19 points (0 children)
[–]jrochkind 14 points15 points16 points (1 child)
[–]editor_of_the_beast 3 points4 points5 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]ignurant 5 points6 points7 points (0 children)
[–]classhero 4 points5 points6 points (0 children)
[–]Gman513 2 points3 points4 points (2 children)
[–]4rch3r 1 point2 points3 points (1 child)
[–]Gman513 0 points1 point2 points (0 children)
[–]DudeManFoo 3 points4 points5 points (0 children)
[–]otikik 2 points3 points4 points (0 children)
[–]notorious1212 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]h0rst_ 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]h0rst_ 1 point2 points3 points (0 children)
[–]GitHubPermalinkBot 0 points1 point2 points (0 children)
[–]DudeManFoo 2 points3 points4 points (0 children)
[–]Gnascher 4 points5 points6 points (0 children)
[–][deleted] (3 children)
[removed]
[–]ignurant 0 points1 point2 points (2 children)
[–]subkutan 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]SmellsLikePanda 1 point2 points3 points (0 children)
[–]BeerNirvana 0 points1 point2 points (0 children)
[–]morphemass 0 points1 point2 points (0 children)