title: How do I force a variable to be initialized in a JavaFX object?
body: <p>I am making a javaFX class and I need one of the variables to be initialized in order for it to work (in my program there's no default value I can use). This is the best I've come up with, but I'd like something that wont compile unless you initialize the variable.</p>
  
  <p>Example Class:</p>
  
  <pre><code>Public class Class1{
  
      public-init var var1:String;
  
      postinit{
          if(var1 == null){
              println("You need to initialize var1");
          }
  }
  </code></pre>
  
  <p>I'd call it like this:</p>
  
  <pre><code>var object1 = Class1{var1:"input"};
  </code></pre>
  
  <p>How can I prevent it from compiling if I do this?</p>
  
  <pre><code>var object1 = Class1{};
  </code></pre>