Notifications
Clear all
[Closed] I like structs! calling private functions
Sep 23, 2016 12:19 pm
It’s surely something basic, but I’ve found it by my own and I like it:
myFunctions =
(
struct myFunctions
(
private
fn kkk = (print "kkk"),
fn ppp = (print "ppp"),
fn qqq = (print "qqq"),
public
fn myFunction id=
(
case id of
(
1: kkk()
2: ppp()
3: qqq()
)
)
)
myFunctions()
)
for id = 1 to 3 do (myFunctions.myfunction id)
2 Replies
Sep 23, 2016 12:19 pm
And if private functions have parameters:
myFunctions =
(
struct myFunctions
(
private
fn kkk a d = (print (a+d)),
fn ppp b = (print b),
fn qqq c = (print c),
public
fn myFunction id a: b: c: d: =
(
case id of
(
1: kkk a d
2: ppp b
3: qqq c
)
)
)
myFunctions()
)
for id = 1 to 3 do (myFunctions.myfunction id a:"aa" d:"dd")
And similar for functions with default values.
Sep 23, 2016 12:19 pm
DenisT was talking about that long time ago also. Really useful things