Why attr_reader


I did not get as to why are we using the keyword attr_reader here? We are not accessing the attributes from outside the class, so why do we need it?


I think balance should not be attr_reader, cause the method display_balance says you need pin_number to display/access balance. Otherwise we could just use my_account.balance right?


I have pretty much the same question. I was wondering why we actually used the attr_reader as well, since we excplicitly define a method to read the balance only if the required pin is correct. Couldn't we just leave it out? It does not make any sense to me, in fact it's pretty dumb to have it inside the class since you don't need the pin anymore to access the balance by just typing my_account.balance in the console. So why did you guys put it in there? :smiley: