1. create a class file named Data.fx
public class Data{
public var name: String;
public var city: String;
public var age: Integer;
public function setName(name){
this.name = name;
}
public function getName(){
return this.name;
}
}
2. Create a var to Object literal in main program
var lady = Data{
name: "Lady Gaga";
city: "New York";
age: 24;
}
3. Now you are ready to use it:
println("Name: {lady.name}");
println("City: {lady.city}");
println("Age: {lady.age}");
lady.setName("Stefani Joanne Angelina Germanotta");
println(lady.getName());
No comments:
Post a Comment