Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peculiar Tcl syntax

Tags:

tcl

I see the following in a Tcl script:

If { <some_condition> } {
  // code here...
} {
  // code here...
}

I am assuming this is a special case of if-else syntax? Would just like to get confirmation.

like image 633
czchlong Avatar asked Jun 17 '13 19:06

czchlong


1 Answers

This is indeed just a variation on if-else syntax; the else is optional (as is the then, which virtually everyone omits but I like to use when I have a multi-line expression before it). It's usually a good idea to include it as that's less visually confusing, but you don't need it.

The only “keywords” in if syntax that are mandatory are if (you could rename that, but it would break all sorts of things) and elseif (for extra condition checks).

like image 93
Donal Fellows Avatar answered Sep 28 '22 23:09

Donal Fellows