Re: if 'also' else statment
On Fri, 08 Jan 2010 11:41:41 +0000, Paul wrote:
> 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.
> if (Day == Saturday)
> else if (Day == Sunday)
Can you re-write that in a way which reflects how C interprets it?
I.e. starting with:
if (Day == Saturday)
if (Day == Sunday)
At this point, is the "also" associated with the outer "if" or the inner
Note that C doesn't have an "else if" statement. The "else" clause can
contain any statement; this can be an "if" statement, or something else.
Even if it *is* an "if" statement, it doesn't get treated any differently
because it's an "if" statement or because it's within an "else" clause.
|All times are GMT. The time now is 08:02 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.