Is it possible to initialize a `val` property in a...
# getting-started
j
Is it possible to initialize a
val
property in an
init
block? I want to find a value in a collection (or null if not found), then set the property to whatever I find. If I use
var
or a custom getter, auto-non-null casting stops working. My current solution is to have a method that does the finding, and set the property to the return value of the method (but I don't like this since then I have an extra function that I only use once, for initialization). https://gist.github.com/jdkula/439902e0d303ba97e2efa5aa3ce71469