T
Ted Zlatanov
PS> Stylistic concerns aside, the original poster's statement returns the
PS> value of the attribute if no argument is passed to the method, a common
PS> mixed getter/setter pattern. You'd need to add a return statement and
PS> repeat the hash key anyway to get that behavior.
Yeah, I wasn't trying to fix all the code, just the part that hurt my
eyes
I'd suggest Moose in general for this kind of drudgery, unless
performance was a concern. Writing your own setters and getters is kind
of a pain to do *right*, and quite a few book chapters have been devoted
to it, with varying degrees of success. Once you add validation,
optional and compound parameters, initializers, and so on, it's quickly
obvious that you're reinventing Moose.
Ted
PS> value of the attribute if no argument is passed to the method, a common
PS> mixed getter/setter pattern. You'd need to add a return statement and
PS> repeat the hash key anyway to get that behavior.
Yeah, I wasn't trying to fix all the code, just the part that hurt my
eyes
I'd suggest Moose in general for this kind of drudgery, unless
performance was a concern. Writing your own setters and getters is kind
of a pain to do *right*, and quite a few book chapters have been devoted
to it, with varying degrees of success. Once you add validation,
optional and compound parameters, initializers, and so on, it's quickly
obvious that you're reinventing Moose.
Ted