lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 3/29/14 1:14 AM, Rena wrote:
> That sounds really cool. I wonder though what is meant by
> Destructuring assignment, parameter guards and richer type system?
Destructuring assignment:

local t = { answer = 42, { "a", "b" } }
local { answer = x, { y, z } } = t
print x, y, x  -- prints: 42  a  b

Parameter guards:

function greet(whom is String)
   print "Hello", whom

greet(42)  -- Error: bad argument #1 to 'greet' (String expected got Number)

By richer type system I mean Shine has nominal types (classes, basically):

class A end
class B extends A end

b = B()
assert b is A  -- true
assert b is B  -- also true

It's all in the docs ;-)