Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
    • Thanks perfect!

      I haven't made up my mind whether accessors that return the object are such a good idea. Say, for example, you have some basic code:

      package DoStuff;
      .... code to make accessors goes here. We have get_foo and set_foo.

      sub make_foo_value {
      $self = shift;
      $self->set_foo(rand)

      }

      package main;

      my $stuff = DoStuff->new;
      $stuff->make_foo_value;

      What should make_foo_value return? If it returns $self, then you need to go:

      print $stuff->make_foo_value->get_foo;

      On the other hand, if it returns the value you just set, you go:

      print $stuff->make_foo_value;

      What is better? Trying to make these sorts of decisions does my head in :)