
5 days per week, a ruby 💡tip - By @blaked_84
🇫🇷
Joined July 2018
- Tweets81
- Following1
- Followers459
- Likes16
Splat operator and array
💻 Copyable example at: beckr.fr/daily_ruby_tips
Writing large Integers
💻 Copyable example at: beckr.fr/daily_ruby_tips
Here documents
📖 Doc: ruby-doc.org/core-2.5.0/doc/…
💻 Copyable example at: beckr.fr/daily_ruby_tips
4
Enumerable#find
Do you know you can pass a proc to `find` to return a default value if no object matches?
📖 Doc: ruby-doc.org/core-2.5.1/Enum…
💻 Copyable example at: beckr.fr/daily_ruby_tips
Enumerable#partition
📖 Example from ruby-doc: ruby-doc.org/core-2.5.1/Enum…
💻 Copyable example at: beckr.fr/daily_ruby_tips
Unescaping text.
Sometime I have to handle escaped text and... no regex tip here. Since ruby 2.5 I use `undump` 😀
📖 Doc: ruby-doc.org/core-2.5.0/Stri…
💻 Copyable example at: beckr.fr/daily_ruby_tips
`split` is not the only solution to split strings.
📖 Doc: ruby-doc.org/core-2.5.0/Stri… & ruby-doc.org/core-2.5.0/Stri…
💻 Copyable example at: beckr.fr/daily_ruby_tips
String#strip
I'm sure you know "strip". What about "strip!", "lstrip" and "rstrip"?
📖 Doc: ruby-doc.org/core-2.5.0/Stri…
💻 Copyable example at: beckr.fr/daily_ruby_tips
4
String#center
Before, I used `puts "###### Title ######"` to print title in stdout. But I hated to center a text manually. Now I use 👇
📖 Doc: ruby-doc.org/core-2.5.0/Stri…
💻 Copyable example at: beckr.fr/daily_ruby_tips









