RosettaCodeData/Task/Classes/Blz/classes.blz

17 lines
349 B
Plaintext

# Constructors can take parameters (that automatically become properties)
constructor Ball(color, radius)
# Objects can also have functions (closures)
:volume
return 4/3 * {pi} * (radius ** 3)
end
:show
return "a " + color + " ball with radius " + radius
end
end
red_ball = Ball("red", 2)
print(red_ball)
# => a red ball with radius 2