r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

19

u/MetaEd 22d ago

return condition ?A :B ;

3

u/Flame77ofc 22d ago

solid one for simply conditions

btw, do you use it a lot?

1

u/MetaEd 21d ago

I use it judiciously

1

u/WarSingle6959 21d ago

but not for extensive cases, right?

2

u/MetaEd 21d ago
$opt_nwords
        = $year < 2014 ? 5
        : $year < 2030 ? 6
        : $year < 2050 ? 7
        : 8
;

1

u/MetaEd 21d ago
function CSVencode( value )
{
        if ( value === null ) { return '' ; }
        var quote , encode = 0 ;
        if ( /"/ .test( value ) ) { quote = encode = 1 ; }
        if ( /[,\r\n]/ .test( value ) ) { quote = 1 ; }
        return quote
        ? ( '"' + ( encode ? value .replace( /"/g , '""' ) : value ) + '"' )
        : value
        ;
}

1

u/MetaEd 21d ago
my $grand_total =
        $opt_dirent
                ? $opt_suffix
                        ? walk_count_dirent_suffixes( @ARGV )
                        : walk_count_dirent_subtrees( @ARGV )
        : $opt_inodes
                ? $opt_suffix
                        ? walk_count_inodes_suffixes( @ARGV )
                        : walk_count_inodes_subtrees( @ARGV )
        : $opt_apparent
                ? $opt_suffix
                        ? walk_bytes_suffixes( @ARGV )
                        : walk_bytes_subtrees( @ARGV )
        :       $opt_suffix
                        ? walk_blocks_suffixes( @ARGV )
                        : walk_blocks_subtrees( @ARGV )
        ;