Is it possible to pass multiple parameters to a method? Suppose I want to have a method that solves for x in the quadratic equation, ax^2 + bx +c =0. We know the equation is ((-b + (b*b -4*a*x) sqrt))/(2*a). I want to pass a, b, and c to a method that might be called quadraticSolution. This is a hypothetical question but its answer will help me with something on which I am working.
"Charles" == Charles Gray tcykgreis@gmail.com writes:
Charles> Is it possible to pass multiple parameters to a method? Suppose I want Charles> to have a method that solves for x in the quadratic equation, ax^2 + Charles> bx +c =0. We know the equation is ((-b + (b*b -4*a*x) sqrt))/(2*a). I Charles> want to pass a, b, and c to a method that might be called Charles> quadraticSolution. This is a hypothetical question but its answer will Charles> help me with something on which I am working.
The method name reflects the number of parameters:
anObject unaryMessage. "unary message takes no parameters" anObject + anotherObject. "binary message is punctuation, takes one parameter" anObject takes: aParameter and: anotherParameter "keyword message"
A keyword message takes one parameter following each colon-terminated word. In this case, the name of the message is "takes:and:".
For a solver, you'd probably have:
result := theSolver solveQuadraticEquationForA: a andB: b andC: c.
or something like that.
beginners@lists.squeakfoundation.org