I have tried to realize adding numbers in lua:
local Calculator = {};
function Calculator.get( frame )
local new_args = str._getParameters( frame.args, { 'f', 'o', 's' } );
local f = tonumber( new_args['f'] ) or 1;
local o = ( new_args['o'] ) or "";
local s = tonumber( new_args['s'] ) or 1;
Calculator.ret(first, second, operation);
end
function Calculator.ret (f, o, s)
if(o == "+") then return f+s;
end
return Calculator
Even if place a end in end, error doesn't disappear.
Calculator.ret(first, second, operation)is also wrong.first,secondandoperationarenil. your variables aref,oands. And the order of parameters is also wrong. You should callCalculator.ret(f, o, s). Also using () in the if-statement is not necessary. Further you don't use the return value of your Calculator.ret call, so your Program doesn't actually do much - Piglet