Daily Ruby Tips (@daily_ruby_tips) header
Daily Ruby Tips (@daily_ruby_tips) profile picture

5 days per week, a ruby 💡tip - By @blaked_84

🇫🇷
Joined July 2018
Get last output in console
7
Splat operator and array 💻 Copyable example at: beckr.fr/daily_ruby_tips
1
2
8
Writing large Integers 💻 Copyable example at: beckr.fr/daily_ruby_tips
1
8
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
1
2
10
Enumerable#partition 📖 Example from ruby-doc: ruby-doc.org/core-2.5.1/Enum… 💻 Copyable example at: beckr.fr/daily_ruby_tips
2
17
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
2
11
`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
1
1
4
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
String#casecmp? If as me, you currenlty use `"aBcDeF".downcase == "abcdeF".downcase` look at this 👇 📖 Example from the ruby doc: ruby-doc.org/core-2.5.0/Stri… 💻 Copyable example at: beckr.fr/daily_ruby_tips
2
12
Struct VS OpenStruct 💻 Copyable example at: beckr.fr/daily_ruby_tips
8
I ❤️Struct! Struct provides a nice way to organise data inside a class. Exemple inspired by this article by @leighchalliday leighhalliday.com/ruby-struc… 📖 Doc: ruby-doc.org/core-2.5.0/Stru… 💻 Copyable example at: beckr.fr/daily_ruby_tips
1
3
11
We continue with other Time tips. And if like me, you never remember the strftime syntax – from ISO 8601, yes it is standard – you can use foragoodstrftime.com by @mbuckbee. 💻 Copyable example at: beckr.fr/daily_ruby_tips
1
7
Today I discovered the `itself` method. It's a kind of public `self`. And I wondered if there is real world usage of this method. 👇 👉Example from karolgalanciak.com/blog/2017… by @Azdaroth 💻 Copyable example at: beckr.fr/daily_ruby_tips
2
1
16