June 2017
Beginner
330 pages
7h 30m
English
One of my favorite features in Ruby is how explicit many of its methods are, and splat may be one of my preferred arguments. The splat argument allows developers to pass an array of values into a method. Imagine that we are building a program that manages a baseball team. If we had a roster method that printed out all of the player names, it would be messy to try to pass all of the names into the method one by one.
For example, this is what it would look like if we simply tried to pass three players into the method manually:
def roster player1, player2, player3 puts player1 puts player2 puts player3 end roster 'Altuve', 'Gattis', 'Springer'
Technically, this code would work. However, this is a trivial example; ...
Read now
Unlock full access