Ильич, а где ООП? ;)

MS

15 октября 2015 г., 9:55 пользователь Илья Винокуров <[email protected]>
написал:

>
> Здравствуйте, комрады!
>
> Как-то так...
>
> my ($father, $mother, $email, $homepage, $date_of_birth) = (
>   $person->get_father // undef,
>   $person->get_mother // undef,
>   $person->get_email // undef,
>   $person->get_homepage // undef,
>   $person->get_date_of_birth // undef
> );
>
> push @person_row,
>     $father && $father->get_id,
>     $mother && $mother->get_id,
>     $email,
>     $homepage,
>     $date_of_birth ? join('/', $date_of_birth->day // '',
> $date_of_birth->month // '', $date_of_birth->year // '') : '';
>
>
> С почтением,
>   Илья Винокуров.
>
> Четверг, 15 октября 2015, 5:43 +03:00 от Nikolay Mishin <[email protected]>:
>
>
> Hi Moscow.PM!
>
> Существует ли какой-либо сбособ сделать более читаемым такой код?:
>
>     push @person_row, (defined $person->get_father()) ?
> $person->get_father()->get_id() : undef;
>     push @person_row, (defined $person->get_mother()) ?
> $person->get_mother()->get_id() : undef;
>     push @person_row, ($person->get_email(), $person->get_homepage());
>
>     my $date = "";
>     if(defined $person->get_date_of_birth()) {
>       my $date_of_birth = $person->get_date_of_birth();
>       $date .= defined $date_of_birth->day ? $date_of_birth->day."/" : "";
>       $date .= defined $date_of_birth->month ? $date_of_birth->month."/" :
> "";
>       $date .= defined $date_of_birth->year ? $date_of_birth->year : "";
>     }
>
> источник
> https://github.com/mishin/Ftree-cpan/blob/master/lib/Ftree/Exporters/ExcelExporter.pm#L53
>
> --
> С уважением
> Николай Мишин
>
> --
> Moscow.pm mailing list
> [email protected] <https://e.mail.ru/compose?To=moscow%[email protected]> |
> http://moscow.pm.org
>
>
>
> --
> Moscow.pm mailing list
> [email protected] | http://moscow.pm.org
>
>


-- 
С уважением
Михаил Шогин.
-- 
Moscow.pm mailing list
[email protected] | http://moscow.pm.org

Ответить