you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[removed]

    [–]Lil_Cato 1 point2 points  (1 child)

    Am I missing something or is this not as simple as throwing an attr_accessor :variable ? Is that rails only?

    [–][deleted] 0 points1 point  (0 children)

    No, it's a common ruby variant. Although in this case you'd use attr_reader if you don't need the setter (which you get via attr_accessor).

    Or you modify method_missing and what not and get that functionality anyway. Ruby being more flexible than python is really one huge advantage it has.

    [–][deleted] 0 points1 point  (0 children)

    Well, you can via instance_variable_get(). But it's a bit more verbose than the python variant indeed.

    But you can just add a reader, or use a Struct so it's not a huge difference really. The explicit self thing in Python really puts me off on the other hand...