ðŸŽ‰ Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io ðŸŽ‰

JaeHyoLee's solution

to Hello World in the Lua Track

Published at Jul 13 2018 · 3 comments
Instructions
Test suite
Solution

The classical introductory exercise. Just say "Hello, World!".

"Hello, World!" is the traditional first program for beginning programming in a new language or environment.

The objectives are simple:

• Write a function that returns the string "Hello, World!".
• Run the test suite and make sure that it succeeds.
• Submit your solution and check it at the website.

If everything goes well, you will be ready to fetch your first real exercise.

Running the tests

To run the tests, run the command `busted` from within the exercise directory.

Further information

For more detailed information about the Lua track, including how to get help if you're having trouble, please visit the exercism.io Lua language page.

Source

This is an exercise to introduce users to using Exercism http://en.wikipedia.org/wiki/%22Hello,_world!%22_program

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

hello-world_spec.lua

``````-- Require the hello-world module
local hello_world = require('hello-world')

-- Define a module named hello-world. This module should return a single
-- function named hello that takes no arguments and returns a string.

describe('hello-world', function()
it('says hello world', function()
local result = hello_world.hello()
assert.are.equal('Hello, World!', result)
end)
end)``````
``````local hello_world = {}
function hello_world.hello(name)
local result = 'Hello, '
if name == nil then
result = result .. 'world!'
else
result = result .. name.. '!'
end
return result
end
return hello_world``````

Hey, good to see you here :)

Solution Author