ഫലകത്തിന്റെ സംവാദം:Switch

message: __TOC__

message: == Purpose ==
To show one specific branch out of multiple possible branches, dependent on a given value.
== Usage ==
 
where VALUE-TO-BE-TESTED is a parameter or a variable
=== Constraints ===
*The variable to switch have some constraints because the value must be able to be used as a parameter name. Characters known not to work are:
** =|
*There is no fall-through (if you look at the code, you know why). 
*If default is not defined, the result if no value matches will be blank.
== Example ==
This code…	…gives this result
	
== How "switch" works ==
It works by the principle that a parameter declaration can be defined by the value of another parameter.
When we access the parameter, we don't have the name hard coded, but we rely on the value of another parameter (in this case the parameter 1).
In its simplest form it is just like  (), but to make it more user friendly and remove the risk trying to access parameter 1, the string case:  was added to the parameters to check for.
Also there is an additional parameter default that can be used if you want to have a default value (no other case value matches).
The resulting code is:

== See also ==
replies: text: *if

text: *m:Help:Array

text: *control flow: choice based on specific constant values

text: *switch statement in C

text: *switch statement in Javascript
==History ==
; Created : --ViswaPrabha (വിശ്വപ്രഭ) 15:56, 7 ഫെബ്രുവരി 2006 (UTC) ( From en Wikipedia)
----
thread_title: Documentation

message: To show one specific branch out of multiple possible branches, dependent on a given value.
thread_title:  Purpose 

message: {{switch
  | VALUE-TO-BE-TESTED
  | case: foo=hello
  | case: bar=world
  | default=Neither foo nor bar
 }}
where VALUE-TO-BE-TESTED is a parameter or a variable
=== Constraints ===
*The variable to switch have some constraints because the value must be able to be used as a parameter name. Characters known not to work are:
** =|
*There is no fall-through (if you look at the code, you know why). 
*If default is not defined, the result if no value matches will be blank.
thread_title:  Usage 

message: *The variable to switch have some constraints because the value must be able to be used as a parameter name. Characters known not to work are:
** =|
*There is no fall-through (if you look at the code, you know why). 
*If default is not defined, the result if no value matches will be blank.
thread_title:  Constraints 

message: This code…	…gives this result
{{switch
  |{{CURRENTDOW}}
  |case: 1=Mon
  |case: 2=Tue
  |case: 3=Wed
  |case: 4=Thu
  |case: 5=Fri
  |case: 6=Sat
  |case: 0=Sun
  |default=No date
}}
thread_title:  Example 

message: It works by the principle that a parameter declaration can be defined by the value of another parameter.
When we access the parameter, we don't have the name hard coded, but we rely on the value of another parameter (in this case the parameter 1).
In its simplest form it is just like  ({{{{{{2|}}}|}}}), but to make it more user friendly and remove the risk trying to access parameter 1, the string case:  was added to the parameters to check for.
Also there is an additional parameter default that can be used if you want to have a default value (no other case value matches).
The resulting code is:
{{{case: {{{1|}}}|{{{default|}}}}}}
thread_title:  How "switch" works 

message: :*if
replies: text: *m:Help:Array

text: *control flow: choice based on specific constant values

text: *switch statement in C

text: *switch statement in Javascript
thread_title:  See also 

message: ; Created : --ViswaPrabha (വിശ്വപ്രഭ) 15:56, 7 ഫെബ്രുവരി 2006 (UTC) ( From en Wikipedia)
----
thread_title: History 

thread_title: Discussion