Last active
December 14, 2015 02:10
-
-
Save daiando/8b18a63a8c99b422586b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def full_name(first, *rest) | |
array = [] | |
rest.map{|x| array << x } | |
array2 = [] | |
return error if first == nil | |
array2 << first | |
array2.concat(array).join(" ") | |
end | |
### array "names" includes all arguments | |
def full_name(*names) | |
return error if names.length < 2 | |
names.join(" ") | |
end | |
#full_name('Harsha', 'Bhogle') => "Harsha Bhogle" | |
#full_name('Pradeep', 'Suresh', 'Satyanarayana') => "Pradeep Suresh Satayanarayana" | |
#full_name('Horc', 'G.', 'M.', 'Moon') => "Horc G. M. Moon" | |
#full_name('Marc') # error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment