mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-24 16:11:04 +00:00
__tostring example added
This commit is contained in:
parent
adb2381b4f
commit
4e968529dc
@ -3,14 +3,14 @@ proto test
|
|||||||
self.setArg(x)
|
self.setArg(x)
|
||||||
end
|
end
|
||||||
|
|
||||||
function fact(self)
|
function __tostring(self)
|
||||||
var total = 1
|
var total = 1
|
||||||
|
|
||||||
for (var i = self.x; i > 0; i = i - 1) do
|
for (var i = self.x; i > 0; i = i - 1) do
|
||||||
total = total * i;
|
total = total * i;
|
||||||
end
|
end
|
||||||
|
|
||||||
return total
|
return "The factorial of " .. self.x .. " is " .. total
|
||||||
end
|
end
|
||||||
|
|
||||||
function setArg(self, x)
|
function setArg(self, x)
|
||||||
@ -24,6 +24,6 @@ for (var x = 1; x < 1000; x = x + 1) do
|
|||||||
for (var i = 1; i < 100; i = i + 1) do
|
for (var i = 1; i < 100; i = i + 1) do
|
||||||
t.setArg(i)
|
t.setArg(i)
|
||||||
|
|
||||||
print(t.fact())
|
print(t)
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user