diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-01-04 11:55:49 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-01-04 11:55:49 +0100 |
commit | ae2f864873a8af097b1b4ec5ff020ec2d8d33d85 (patch) | |
tree | 4e66a727de97c9c35739e36aaf1f3371482ef0a9 | |
parent | 86937cf26e87ad707aebeea202854fad6ab0073a (diff) | |
download | applause2-ae2f864873a8af097b1b4ec5ff020ec2d8d33d85.tar.gz |
allow constructors to return other things than class instances
* could be used to introduce classes like SinOsc that are simply shortcuts
for some higher order stream (just like Stream.SinOsc is currently) but
can be instantiated consistently using SinOsc:new().
-rw-r--r-- | applause.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/applause.lua b/applause.lua index d598a86..1455dc5 100644 --- a/applause.lua +++ b/applause.lua @@ -98,9 +98,9 @@ function DeriveClass(base, ctor) setmetatable(obj, self) - if ctor then ctor(obj, ...) end - - return obj + -- Allow constructors to return something else + -- than an instance of the class. + return ctor and ctor(obj, ...) or obj end return class |