Stuart R. Jefferys
Stuart R. Jefferys

Reputation: 963

Is it ever necessary to end a (perl) Moose class with 1;?

I'm new to Moose, and by the Moose manual on classes it seems that a valid class is:

package Person;
use namespace::autoclean;
use Moose;

__PACKAGE__->meta->make_immutable;

But where is the terminal "I'm returning true" 1; ???

I can find many example of Moose classes that do end with 1; but is this useless or is it sometimes necessary (and why)? Since I can also find many examples of Moose classes with use strict; and use warnings;, which are definitely redundant, it seems that some old perl habits die hard.

Upvotes: 3

Views: 268

Answers (1)

ikegami
ikegami

Reputation: 385996

No, $meta->make_immutable is guaranteed to return a true value.

This method will create an immutable transformer and use it to make the class and its metaclass object immutable, and returns true (you should not rely on the details of this value apart from its truth).

Upvotes: 4

Related Questions