One of my favorite feature of ES6 is the
spread operator that is represented by
.... It is comparable in Ruby to the
I use this feature all the time in my code, it really simplify the code readability by removing repetition.
You can use it to merge array:
# ruby array = [1, 2] newArray = [*array, 3, 4] # => [1, 2, 3, 4];
Call a function that can get an unknown number of arguments:
# ruby def foo(*args) puts args.size # => 3 end foo('a', 'b', 'c');
Here is an example of refactoring by using the spread operator for the Timeshift library:
Here is a link to the commit.