Class constructors
public class CustomClass{
//all the variables
public let myInt: Int32;
public let myString: String;
}let myCustomClass = new CustomClass();
myCustomClass.myInt = 1;
myCustomClass.myString = "Hello";public class CustomClass{
//all the variables
public let myInt: Int32;
public let myString: String;
public static func Create(inputInt: Int32, inputString: String) -> ref<CustomClass>{
//you create the new instance of your class here instead of in your code
//and set its variables
let self = new CustomClass();
self.myInt = inputInt;
self.myString = inputString;
return self;
}
}Last updated
Was this helpful?