To caps or not to caps that is the question?

Steve smorrey at gmail.com
Tue Dec 18 16:31:44 MST 2007


Yeah that part was intentional.  Not to many words have double letter
beginnings.
I like your idead about trimming that ternary statement, it clears it up a bit.

On Dec 18, 2007 4:25 PM, Eric Wald <eswald at brainshell.org> wrote:
> Steve wrote:
> > newval = (myval == someval) ? somefunction : otherfunction;
> > Expands out to...
> > if(myval == someval)
> > {
> >    newval = somefunction;
> > }else{
> >    newval = otherfunction;
> > }
>
> No, it expands out to
>
>   if (myval == someval) {
>      newval = somefunction;
>   } else {
>      newval = otherfunction;
>   }
>
> > That works great on it's own, but if I'm trying to do it as part of
> > another larger statement it makes the whole statement overall less
> > clear.
>
> The statement in question, however, is a separate beast.
>
>   letter = (counter == 0) ? toupper(letter) : letter;
>
> is better expressed as
>
>   if (!counter) letter = toupper(letter);
>
> Even the first double-length line is better expressed as a ternary
> inside an if, to avoid the same kind of assignment to self, and to avoid
> confusing the reader with nested ternary operators:
>
>   if (letter == oldletter) {
>     letter = (coin <= 60)? PickChar(vowels): PickChar(consonants);
>   }
>
> What I find most odd, though, is that you never pick a new character
> first, so this conditional is always true after the first iteration.
>
> - Eric
>
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */
>



More information about the PLUG mailing list