Question

5. What does it mean to pass a parameter to a method? What happens when a pa- rameter is passed to a method?
I want that answer in ruby
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Parameter Passing to a Method Means That , Input To the Method, In SImple Word You, Method accept Input that you can pass as a Parameter to method based on this Input parameter, Method will perform Operation and Will return the Output. So think for a Example. A Method is factory , Parameter is Input to factory and based On these Inputs factory will perform operation and Process output.

So , It is Mechanism used to pass parameter to function or Procedure or Method. Basically there are two types of It.

1)If value of Actual parameter is getting Passed it is called as Call by value.

2) if the Adress of memory location of Actual parameter is passed it is called as Call By reference .

In Ruby You can Pass a Parameter Like this:-

def samplemethod(var1 , var2)

expression

end

here var1 and var2 are parameter to the Method name samplemethod.

Even in Ruby you can set the default value for the parameter , that can be used when method will called without Parameter Example is Like in Ruby:-

def sampleTestMehod(variable1 = value1 , variable2 = value2)

expression

end

i hope You got the fair idea about the topic in case of any doubt and query please let me know in comments , i will be happy to help you. thanks.

Add a comment
Know the answer?
Add Answer to:
I want that answer in ruby 5. What does it mean to pass a parameter to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT