
5 days per week, a ruby 💡tip - By @blaked_84
🇫🇷
Joined July 2018
- Tweets81
- Following1
- Followers458
- Likes16
Pinned Tweet
Subscriptions are now open for the @daily_ruby_tips newsletter!
📅 1 mail / week
📁 all the tips of the week
👉 beckr.fr/daily_ruby_tips
I haven't started posting tips yet, but I'm hiring a Ruby on Rails + Vue.js dev.
French + english speaking
👇
Evalmee.com is hiring a Ruby/Vue.js dev!
🚀 We're building an online exam platform for higher education & professional training, and looking for people who can pick a problem and solve it.
🎓 >4 years of exp
🇫🇷 Paris or full remote
evalmee.welcomekit.co/jobs/d…
Splat operator and array
💻 Copyable example at: beckr.fr/daily_ruby_tips
More examples ⬇️
xitter.cf/daily_ruby_tips/status…
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
😱 There is an error in today's tip!
Thanks you @Jauny!
You should read this 👇
Replying to @daily_ruby_tips
shouldn't the return of find e[:a] == 1 be {:a=>1, :b=>2} instead of {:a=>2, :b=>3}?!
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
Would you be interested to see Rails tips on @daily_ruby_tips ?
93%Yes
7%No
91 votes • Final resultsEnumerable#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
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
Reduce
📖 Example from ruby doc: ruby-doc.org/core-2.5.1/Enum…
💻 Copyable example at: beckr.fr/daily_ruby_tips
Struct VS OpenStruct
💻 Copyable example at: beckr.fr/daily_ruby_tips
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
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



















