Nested function: Difference between revisions
Content deleted Content added
Examples for nested functions |
Lua |
||
Line 21: | Line 21: | ||
} |
} |
||
Console.WriteLine(MakeList(". ")); |
|||
</lang> |
</lang> |
||
Line 36: | Line 36: | ||
return makeItem("first") + makeItem("second") + makeItem("third"); |
return makeItem("first") + makeItem("second") + makeItem("third"); |
||
} |
} |
||
console.log(makeList(". ")); |
|||
</lang> |
|||
=={{header|Lua}}== |
|||
<lang lua> |
|||
function makeList(separator) |
|||
local counter = 1 |
|||
local function makeItem(item) |
|||
return counter .. separator .. item .. "\n" |
|||
end |
|||
return makeItem("first") .. makeItem("second") .. makeItem("third") |
|||
end |
|||
print(makeList(". ")) |
|||
</lang> |
</lang> |
||