For the complete documentation index, see llms.txt. This page is also available as Markdown.

Break OO privacy

Sidef's object model does not enforce privacy, but it allows storing private attributes inside the container of an object, which is an hash:

class Example {
    has public = "foo"
    method init {
        self{:private} = "secret"
    }
}
 
var obj = Example();
 
# Access public attributes
say obj.public;                 #=> "foo"
say obj{:public};               #=> "foo"
 
# Access private attributes
say obj{:private};              #=> "secret"

Last updated