Skip Menu |

This queue is for tickets about the App-Nopaste CPAN distribution.

Report information
The Basics
Id: 101477
Status: resolved
Priority: 0/
Queue: App-Nopaste

People
Owner: Nobody in particular
Requestors: dean [...] fragfest.com.au
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.003
Fixed in: 1.003



Subject: Advantage of do {} over just () in ::Service
In App::Nopaste::Service, there is this block of code $mech->submit_form( fields => { paste => $args{text}, do { $args{chan} ? (channel => $args{chan}) : () }, do { $args{desc} ? (summary => $args{desc}) : () }, do { $args{nick} ? (nick => $args{nick}) : () }, private => (exists $args{private} && $args{private} ? 1 : 0), }, ); I am curious what the advantage of do {} is over simply wrapping with ()'s ie. ( $args{chan} ? (channel => $args{chan}) : () ), Cheers
On 2015-01-11 15:44:16, djzort wrote: Show quoted text
> In App::Nopaste::Service, there is this block of code > > $mech->submit_form( > fields => { > paste => $args{text}, > do { $args{chan} ? (channel => $args{chan}) : () }, > do { $args{desc} ? (summary => $args{desc}) : () }, > do { $args{nick} ? (nick => $args{nick}) : () }, > private => (exists $args{private} && $args{private} ? 1 : 0), > }, > ); > > I am curious what the advantage of do {} is over simply wrapping with ()'s > > ie. > ( $args{chan} ? (channel => $args{chan}) : () ),
I can't think of any advantage in this situation. Good eye! I'll leave this ticket open to give someone something to do if they happen to get this dist in the PR challenge. :)
Probably my fault. The only reason I can think of that I would do this is because () is a bit more noisy. do {} keeps the syntax clearer. Feel free to change it though, because for better or worse, ($foo ? (bar => 1) : ()) is idiomatic.
Subject: Re: [rt.cpan.org #101477] Advantage of do {} over just () in ::Service
Date: Tue, 13 Jan 2015 10:50:34 +1100
To: bug-App-Nopaste [...] rt.cpan.org
From: Dean Hamstead <dean [...] fragfest.com.au>
Im not concerned to patch the code. Mainly just curious if there was some subtle superiority to that approach. Please close. On 2015-01-13 07:28, Shawn M Moore via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=101477 > > > Probably my fault. The only reason I can think of that I would do this > is because () is a bit more noisy. do {} keeps the syntax clearer. > > Feel free to change it though, because for better or worse, ($foo ? > (bar => 1) : ()) is idiomatic.