![]() | ![]() | |||||||||||||||
|
The @ and % OperandsAdaScript has two short-cut operands provided for scripting and convenience on the command line. Itself (@)AdaScript provides a self-referential operand. "@", pronounced "itself", returns the value of the variable on the left side of an assignment statement. Use @ to save yourself unnecessary typing. => total := @ + 1; -- total := total + 1; (An operand is used instead of C-style "+=", "-=", and so forth because it's much more resilient to typos. Leaving out the "@" or transposing it with the ":=" or "+" will result in a syntax error. In C, these mistakes usually result in legal assignments.) => result := 10 - @; -- impossible with C-style shortcuts When assigning a value to an array, @ refers to the array item being assigned, not the entire array. => zebra_population( 1966 ) := @+1; -- add 1 to 1966 population Common self-referential (or combined operator) shortcuts:
Itsef can also be used as an operator to repeat commands, procedures or pragmas with new parameters. Read this as "and itself with". This is called a a "chain".
=> echo "hello" @ "world" Last Output (%)AdaScript provides a last output operand. "%", pronounced "last output", returns the last put_line (or ?) value. This is similar to Python's last output operand. => put_line( 5*2 ) The type of the last output is remembered. => put_line( 5 ) Use % for quick calculations at the command line.
|
![]() Block Statements and Subprograms |
||||||||||||||||||||||
![]() |
![]() |