r/learnruby • u/seanammers Beginner • May 15 '18
Understanding the concept of placeholders/parameters
Hi there, I'm using the lesson on comparative operators from Codecademy as my example.
I'm not understanding the reason for having two parameters.
I know for my earlier exercises, a single parameter would be what the result of the operation would be placed into.
Could someone help me try to wrap my head around this? Sorry, I know I'm a complete noob.
On a separate issue, I'm pretty sure my verbiage is terrible, trying to describe my issue. How would you guys call what I'm trying to reference?
Like the stuff in between the curly brackets, the whole curly brackets code block itself, I know that .sort is a method.
books.sort! { |firstBook, secondBook|
secondBook <=> firstBook
}Thanks guys!
View all comments
Show parent comment
1
u/seanammers Beginner May 16 '18
Hi there, thank you for your answer.
What is the outcome of the -1, 0, and 1 returns?
Like does -1 reverse the sort, 1 sorts in alphabetical order?
Thanks!