Tuesday, 25 August 2015

Tool Command language -Lecture 4(Use of Switch)

The use of Switch replaces multiple if-else. The syntax is as 
  
switch string pattern 1 body 1 pattern 2 body 2 ... pattern n body n
                                    or
switch string {pattern 1 body 1 pattern 2 body 2... pattern n body n}
example :

set x one
switch $x "ONE" "puts ONE=1" "two" "puts 2"
           or           
set c hate  
switch  $c {
"love" {
puts "i hate u"
 }
"hate" {
 puts "i know"
        }
     }


No comments:

Post a Comment

Grammar Mistakes in Technical Paper Writing

Let me share some experience in this post with you. I'm currently in the second year of my Ph.D. program. We are in the middle of paper...