Classes: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 257:
END obj
ENDPROC</lang>
 
=={{header|Arturo}}==
 
<lang arturo>// Let's define our class
 
Person #{
// first the class variables
name ""
surname ""
age 0
 
// then the constructor (optional)
init [n,s,a]{
name n
surname s
age a
}
 
// then another method (optional again, ofc)
sayHello {
print "Hello " + name + "!"
}
}
 
// Let's create a new Person object
person $(new ~Person "John" "Doe" 33)
 
// Let's invoke an object method
person.sayHello
 
// Let's access some object variable
print "the person's age is: " + person.age
 
// Let's change some of the object's properties
person.surname "boom"
 
// And let's print our object again
// to see what we've done
log person</lang>
 
{{out}}
 
<pre>Hello John!
the person's age is: 33
#{
age 33
init <function: 0x1015A8D40>
name "John"
sayHello <function: 0x1015A8DA0>
surname "boom"
}</pre>
 
=={{header|AutoHotkey}}==
1,532

edits