RosettaCodeData/Task/Break-OO-privacy/Phix/break-oo-privacy.phix
2026-02-01 16:33:20 -08:00

14 lines
484 B
Text

without js -- (no class under p2js)
class test
private string msg = "this is a test"
procedure show() ?this.msg end procedure
end class
test t = new()
t.show()
--?t.msg -- illegal
--t.msg = "this is broken" -- illegal
include builtins\structs.e as structs
constant ctx = test -- magic/context
?structs:fetch_field(t,"msg",ctx)&" (with some magic)"
structs:store_field(t,"msg","this breaks privacy",ctx)
t.show()