This is a Java Code :
public class test{
public static void main(String args[]){
number A = new number();
System.out.println(A.b);
}
}
class number{
int b = 100;
}
Is there a equivalent of above code in ruby without attr_accessor ?
Why can’t we access member variables using ‘.’ like in java ? or is there a way i am unaware of in ruby … ?
If you just want to pass around structured data, then you can use the Ruby
Structclass, which will work more like you’d expect from your example: