Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: if 'also' else statment

Reply
Thread Tools

Re: if 'also' else statment

 
 
TonyMc
Guest
Posts: n/a
 
      01-08-2010
"Paul" <-> writes:

> I sometimes think it would be nice if c had an 'also' statement,
> which meant that 'if a preceeding condition was true, do this as well'.
>
> This might save some untidy work-around, or much worse, copy-
> pasting. Let me know if you have a nice neat alternative.
>
> Here's an example of reading a book on weekends, but not weekdays.
> Naturally, there could be many more things done on a weekend.
>
> P.
>
> if (Day == Saturday)
> {
> WalkInPark();
> }
> else if (Day == Sunday)
> {
> AttendChurch();
> }
> also
> {
> ReadABook();
> }
> else
> {
> GoToWork();
> }


See if you can get your church to meet in the park. Even better, if the
park provides seating and sufficient light for reading (which, I guess
would be a prerequisite for holding church services there), your
conditional expression becomes trivial. If the provisions of the C
language are not a good fit to your lifestyle, it is probably simpler to
change your lifestyle than to introduce new keywords into C.

Tony
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      01-08-2010
TonyMc <(E-Mail Removed)> writes:
>"Paul" <-> writes:
>> if (Day == Saturday)
>> {
>> WalkInPark();
>> }
>> else if (Day == Sunday)
>> {
>> AttendChurch();
>> }
>> also
>> {
>> ReadABook();
>> }
>> else
>> {
>> GoToWork();
>> }


Sorry for indirect quoting, but I missed the OP:

if( day == SATURDAY ) { walk(); we = 1; }
else if( day == SUNDAY ) { attend(); we = 1; }
else { work(); we = 0; }
if( we ) { read(); }

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: if 'also' else statment Nobody C Programming 0 01-10-2010 07:01 AM
Re: if 'also' else statment William McNicol C Programming 2 01-09-2010 12:30 PM
PIX route inside statment John Cisco 1 09-27-2005 03:06 AM
Using "For Each ctrl In.." Statment Inside UserControl crjunk ASP .Net 2 09-03-2004 06:23 PM
Return statment JL ASP .Net 2 12-17-2003 10:47 AM



Advertisments