I wanted to know if there is a way we can make instance variables inaccessible outside of the class. For example, the following snippet (which works and prints 30):
class Point @x : Int32 @y : Int32 def initialize(@x, @y) end end point = Point.new(10, 20) puts point.@x + point.@y
What if I wanted
@y not be accessible from outside the class if I do not define any
property. I think I read in a discussion that instance variables are private by default, is that only in case of writes?
Thanks in advance. I just started learning Crystal two days ago so if I have missed the obvious then apologies in advance too.