User Tools

Site Tools


at:tutorial:basic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:basic [2007/04/17 17:25] tvcutsemat:tutorial:basic [2007/04/17 17:30] tvcutsem
Line 293: Line 293:
  
 Beware of the precedence rules for function application versus method invocation, which may lead to unexpected results, e.g.: Beware of the precedence rules for function application versus method invocation, which may lead to unexpected results, e.g.:
-</code>+<code>
 >-1.abs() >-1.abs()
 >>-1 >>-1
-<code>+</code>
 This code is interpreted as ''-(1.abs())'', hence the result. This code is interpreted as ''-(1.abs())'', hence the result.
  
Line 384: Line 384:
 ==== Booleans ==== ==== Booleans ====
    
- +As any native type, booleans are objects so, they respond to keyword messages such as:
-AmbientTalk supports infix operators for booleans as &, | and !. As any native type, booleans are objects so, they respond to keyword messages such as:+
 <code> <code>
 <booleanexpr>.ifTrue: { ...}  <booleanexpr>.ifTrue: { ...} 
Line 393: Line 392:
 </code> </code>
  
-**=** and **!=** are the infix operators for equality and inequality. **true** and **false** are the boolean constant objects. What follows is some basic examples of boolean manipulation:+''='' and ''!='' are the infix operators for equality and inequality. The prefix operator ''!'' represents logical negation. ''true'' and ''false'' are the prototypical boolean singleton objects. What follows is some basic examples of boolean manipulation:
 <code> <code>
 >(0 < 1).ifTrue: { 0 }  >(0 < 1).ifTrue: { 0 } 
Line 407: Line 406:
 </code> </code>
  
-Boolean infix operators such as & and | are not shortcut. Thus, both arguments will be evaluated. For lazy evaluation, you should use the natives methods. For example, false.and: { 1/0 } will return false without executing the second argument.+Compound boolean expressions can be created by means of a boolean's ''and:'' and ''or:'' methodswhich both take a zero-argument closure as argument. For example, ''false.and: { 1/0 }'' will return ''false''. The block is not applied because a logical //and// with ''false'' always fails.
  
 ===== Control Flow Structures ===== ===== Control Flow Structures =====
at/tutorial/basic.txt · Last modified: 2020/02/09 22:05 by elisag