small wish, I'd like to have the possibility to `i...
# language-proposals
e
small wish, I'd like to have the possibility to
init
without body, eg:
init = bar()
1
4
f
I was thinking the same thing the other day.
😛 1
s
I think that's weird regarding the return type of bar. I think the code suggests that init receives the return value somehow.
1
d
Oh! It took me a moment to realise it wasn't an assignment,
I'm still not sure what it's supposed to be doing? 😕
One liner?
e
of course it's like the
main
,
bar
shall return
Unit
@Dominaezzz
Copy code
init {
   bar()
}
d
Ah I see.
k
I don’t think this is a good idea.
init
is currently the only place you’re allowed to “assign” (initialize) `val`s (outside of initializing inline in the property declaration). If you extract that to a method, people can call it outside of
init
so those statements will be illegal.
j
I get the idea, but it looks wrong. The equals makes sense in the case of defining a function; you're saying that the result of the function is equivalent to the expression on the other side. The equals doesn't make sense in this context.