forked from ground/ground
Function calling in structs
This commit is contained in:
@@ -2,23 +2,28 @@ struct -point
|
||||
init &xpos -int
|
||||
init &ypos -int
|
||||
|
||||
fun -void !init -int &x -int &y
|
||||
fun -int !init -int &x -int &y
|
||||
set &xpos $x
|
||||
set &ypos $y
|
||||
return
|
||||
return 0
|
||||
endfun
|
||||
|
||||
fun -string !toString
|
||||
# do stuff
|
||||
return "placeholder"
|
||||
endfun
|
||||
|
||||
fun -int !dingle
|
||||
return 23
|
||||
tostring $xpos &xposstr
|
||||
tostring $ypos &yposstr
|
||||
add "x: " $xposstr &str
|
||||
add $str ", y: " &str
|
||||
add $str $yposstr &str
|
||||
return $str
|
||||
endfun
|
||||
endstruct
|
||||
|
||||
init &myPoint -point
|
||||
|
||||
set &myPoint.xpos 20
|
||||
pusharg 30 15
|
||||
!myPoint.init &out
|
||||
println $myPoint.xpos
|
||||
|
||||
!myPoint.toString &out
|
||||
|
||||
println $out
|
||||
|
||||
Reference in New Issue
Block a user