class Person {
private _age = 2
public get age() {
return _age
}
protected year = 1990
}
pub struct R2 { // 显式的公共结构
x: Int // 隐式的公共字段
pub y: Int // WARNING: `pub` 是多余的!
priv z: Int // 显式的私有字段
}
pub
class Person
|int| age
setter age
expect (value >= 0) ("bad age $value set!")
.age = value
main
|| p = person()
p.age = -1 // calls a function rather than the property
|| n = p.age // reads the property directly!
Languages with Access Modifiers include Java, C++, PHP, TypeScript, C#, Swift, Kotlin, Solidity, F#, Protocol Buffers, ABAP, C3, Koka, MoonBit, C2, Apex, Jule, Sophia, Speedie
Languages without Access Modifiers include JavaScript, C, progsbase
View all concepts with or missing a hasAccessModifiers measurement
Read more about Access Modifiers on the web: 1.