Created
October 5, 2019 22:58
-
-
Save tamert/9ddd0eb3e8103aa461b1b25f5034c366 to your computer and use it in GitHub Desktop.
* and ** operator
This file contains 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
# * operator | |
def order_pizza(*pizzas) | |
return pizzas | |
end | |
puts order_pizza('Bora', 'Tolga', 'Sevil') | |
# * operator - into Object | |
def frameworks(*lovers) | |
return lovers | |
end | |
we_love = { | |
"name": "React", | |
} | |
you_love = { | |
"name": "Vue", | |
} | |
puts frameworks(we_love, you_love) | |
# ** operator | |
def print_list_of(**books_and_articles) | |
books_and_articles.each do |book, article| | |
puts book | |
puts article | |
end | |
end | |
# As an argument, we define a hash in which we will write books and articles. | |
books_and_articles_we_love = { | |
"Ruby on Rails 4": "What is webpack?", | |
"Ruby essentials": "What is Ruby Object Model?", | |
"Javascript essentials": "What is Object?" | |
} | |
print_list_of(books_and_articles_we_love) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment