Ruby Tips & Tricks
In this article I would to share a few lesser known coding tips & tricks in Ruby language, this has helped me make my code shorter and write code quicker, nevertheless the more you know the higher the chances of finding out some trick yourself.
Sometimes, we need to delete whole directories, and I have seen people resorting to the use of shell command for the purpose, but that is not needed. Ruby has a module fileutils which is better.
This nice trick is very handy, checkout the example below:
Did you know that you can join arrays using the * operator? Here's how:
Applying the * operator to an array with a number will increase the size of the array, but passing a string will join the array using the passed string as delimiter.
Now you would need to combine multiple conditions with and/or, just use this:
Interpolate format strings and substitute with values easily like this:
|All times are GMT +5.5. The time now is 07:37.|