Im looking for a good explanation of what this term means
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In programming, formal arguments (also commonly known as ‘formal parameters’) are the arguments a function expects to receive and assigns names to. They are the arguments that generally act similar to local variables, and are explicitly listed in the function definition. For example, in this method:
The formal arguments are
wordsandoptions. There are also some informal arguments, namelyrepetitionsandno_footer. Semantically, we understand these to be arguments to the function, but they are not formal arguments.There is nothing specific to ruby about formal arguments, but there is some specific significance. In ruby, and especially Rails, many many methods only have a few formal arguments (and a lot of informal arguments). For example, in this call:
The receiving method only really has one formal argument, an options hash.
It’s also worth noting here that ‘formal arguments’ are frequently contrasted with ‘actual arguments’. Actual arguments are simply the values really being passed. So, for example, in this call,
The actual arguments are
"I love ruby"and{:repetitions => 10, :no_footer => true}and these map onto the formal arguments above,wordsandoptions.