Boolean values: Difference between revisions
Content added Content deleted
(added omit from ML/I) |
|||
Line 364: | Line 364: | ||
=={{header|Metafont}}== |
=={{header|Metafont}}== |
||
Metafont has the type <tt>boolean</tt>; a boolean variable can be <tt>true</tt> or <tt>false</tt>. Using non boolean values (or expressions that do not evaluate to a boolean value) results in a recoverable error; by default, any non-boolean value is interpreted as false. |
Metafont has the type <tt>boolean</tt>; a boolean variable can be <tt>true</tt> or <tt>false</tt>. Using non boolean values (or expressions that do not evaluate to a boolean value) results in a recoverable error; by default, any non-boolean value is interpreted as false. |
||
=={{header|Mirah}}== |
|||
<lang mirah>import java.util.ArrayList |
|||
import java.util.HashMap |
|||
# booleans |
|||
puts 'true is true' if true |
|||
puts 'false is false' if (!false) |
|||
# lists treated as booleans |
|||
x = ArrayList.new |
|||
puts "empty array is true" if x |
|||
x.add("an element") |
|||
puts "full array is true" if x |
|||
puts "isEmpty() is false" if !x.isEmpty() |
|||
# maps treated as booleans |
|||
map = HashMap.new |
|||
puts "empty map is true" if map |
|||
map.put('a', '1') |
|||
puts "full map is true" if map |
|||
puts "size() is 0 is false" if !(map.size() == 0) |
|||
# these things do not compile |
|||
# value = nil # ==> cannot assign nil to Boolean value |
|||
# puts 'nil is false' if false == nil # ==> cannot compare boolean to nil |
|||
# puts '0 is false' if (0 == false) # ==> cannot compare int to false |
|||
#puts 'TRUE is true' if TRUE # ==> TRUE does not exist |
|||
#puts 'FALSE is false' if !FALSE # ==> FALSE does not exist |
|||
</lang> |
|||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |