Guía del lenguaje
lang.wlk
Class Exception
Base class for all Exceptions. Every exception and its subclasses
indicates conditions that a reasonable application might want to catch.
since 1.0
Estado
Atributo | WollokDoc |
---|---|
const property message | specified detail message. |
const property cause | specified cause |
Comportamiento
initialize()
Exception.initialize()
Documentation not found
printStackTrace()
Exception.printStackTrace()
Prints this exception and its backtrace to the console
getStackTraceAsString()
Exception.getStackTraceAsString()
Documentation not found
printStackTrace(printer)
Exception.printStackTrace(printer)
Documentation not found
printStackTraceWithPrefix(prefix, printer)
Exception.printStackTraceWithPrefix(prefix, printer)
Documentation not found
createStackTraceElement(contextDescription, location)
Exception.createStackTraceElement(contextDescription, location)
Documentation not found
getFullStackTrace()
Exception.getFullStackTrace()
Documentation not found
getStackTrace()
Exception.getStackTrace()
Provides programmatic access to the stack trace information
printed by printStackTrace().
==(other)
Exception.==(other)
Overrides the behavior to compare exceptions
Class StackOverflowException
Thrown when a stack overflow occurs because an application recurses too deeply.
since 1.5.1
Class ElementNotFoundException
An exception that is thrown when a specified element cannot be found
Class DomainException
An exception that is thrown for domain purpose
Estado
Atributo | WollokDoc |
---|---|
const property source | Documentation not found |
Class EvaluationError
(added by wollok-ts) An exception thrown whenever the interpreter fails to evaluate an expression
Class MessageNotUnderstoodException
An exception that is thrown when an object cannot understand a certain message
Class StackTraceElement
An element in a stack trace, represented by a context and a location
of a method where a message was sent
Estado
Atributo | WollokDoc |
---|---|
const property contextDescription | Documentation not found |
const property location | Documentation not found |
Class Object
Representation of Wollok Object
Class Object is the root of the class hierarchy.
Every class has Object as a superclass.
since 1.0
Comportamiento
initialize()
Object.initialize()
Documentation not found
identity()
Object.identity()
Documentation not found
kindName()
Object.kindName()
Object description in english/spanish/... (depending on i18n configuration)
className()
Object.className()
Full name of Wollok object class
private
==(other)
Object.==(other)
Tells whether self object is "equal" to the given object
This method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value x, x == x should return true.
- It is symmetric: for any non-null reference values x and y, x == y
should return true if and only if y == x returns true.
- It is transitive: for any non-null reference values x, y, and z,
if x == y returns true and y == z returns true,
then x == z should return true.
- It is consistent: for any non-null reference values x and y, multiple invocations
of x == y consistently return true or consistently return false,
provided no information used in equals comparisons on the objects is modified.
- For any non-null reference value x, x == null should return false.
The default behavior compares them in terms of identity (===)
!=(other)
Object.!=(other)
Documentation not found
===(other)
Object.===(other)
Documentation not found
!==(other)
Object.!==(other)
Tells whether self object is not identical (the same) to the given one.
See === message.
equals(other)
Object.equals(other)
Documentation not found
->(other)
Object.->(other)
Documentation not found
toString()
Object.toString()
Documentation not found
shortDescription()
Object.shortDescription()
Documentation not found
printString()
Object.printString()
Provides a visual representation of Wollok Object
By default, same as toString but can be overridden
like in String
messageNotUnderstood(messageName, parameters)
Object.messageNotUnderstood(messageName, parameters)
private
generateDoesNotUnderstandMessage(target, messageName, parametersSize)
Object.generateDoesNotUnderstandMessage(target, messageName, parametersSize)
Documentation not found
error(aMessage)
Object.error(aMessage)
Builds an exception with a message
checkNotNull(value, message)
Object.checkNotNull(value, message)
Documentation not found
Singleton void
Representation for methods that only have side effects
Class Pair
Representation of a Key/Value Association.
It is also useful if you want to model a Point.
Estado
Atributo | WollokDoc |
---|---|
const property x | Documentation not found |
const property y | Documentation not found |
Comportamiento
key()
Pair.key()
Documentation not found
value()
Pair.value()
Documentation not found
==(other)
Pair.==(other)
Documentation not found
toString()
Pair.toString()
Documentation not found
Class Collection
The root class in the collection hierarchy.
A collection represents a group of objects, known as its elements.
Comportamiento
max(closure)
Collection.max(closure)
Answers the element that is considered to be/have the maximum value.
The criteria is given by a closure that receives a single element
as input (one of the element). The closure must return a comparable
value (something that understands the >, >= messages).
If collection is empty, an ElementNotFound exception is thrown.
max()
Collection.max()
Documentation not found
maxIfEmpty(toComparableClosure, emptyCaseClosure)
Collection.maxIfEmpty(toComparableClosure, emptyCaseClosure)
Answers the element that is considered to be/have the maximum value,
or applies a closure if the collection is empty.
The criteria is given by a closure that receives a single element
as input (one of the element). The closure must return a comparable
value (something that understands the >, >= messages).
The closure to execute when the collection is empty is given as a second
argument.
maxIfEmpty(emptyCaseClosure)
Collection.maxIfEmpty(emptyCaseClosure)
Documentation not found
min(closure)
Collection.min(closure)
Answers the element that is considered to be/have the minimum value.
The criteria is given by a closure that receives a single element
as input (one of the element). The closure must return a comparable
value (something that understands the <, <= messages).
min()
Collection.min()
Documentation not found
minIfEmpty(toComparableClosure, emptyCaseClosure)
Collection.minIfEmpty(toComparableClosure, emptyCaseClosure)
Answers the element that is considered to be/have the minimum value,
or applies a closure if the collection is empty.
The criteria is given by a closure that receives a single element
as input (one of the element). The closure must return a comparable
value (something that understands the >, >= messages).
The closure to execute when the collection is empty is given as a second
argument.
minIfEmpty(emptyCaseClosure)
Collection.minIfEmpty(emptyCaseClosure)
Documentation not found
absolute(closure, criteria, emptyCaseClosure)
Collection.absolute(closure, criteria, emptyCaseClosure)
Documentation not found
uniqueElement()
Collection.uniqueElement()
Documentation not found
+(elements)
Collection.+(elements)
Documentation not found
addAll(elements)
Collection.addAll(elements)
Documentation not found
removeAll(elements)
Collection.removeAll(elements)
Documentation not found
removeAllSuchThat(closure)
Collection.removeAllSuchThat(closure)
Documentation not found
isEmpty()
Collection.isEmpty()
Documentation not found
validateNotEmpty(operation)
Collection.validateNotEmpty(operation)
Documentation not found
forEach(closure)
Collection.forEach(closure)
Documentation not found
all(predicate)
Collection.all(predicate)
Documentation not found
any(predicate)
Collection.any(predicate)
Documentation not found
find(predicate)
Collection.find(predicate)
Documentation not found
findOrDefault(predicate, value)
Collection.findOrDefault(predicate, value)
Documentation not found
findOrElse(predicate, continuation)
Collection.findOrElse(predicate, continuation)
Answers the element of self collection that satisfies a given condition,
or the the result of evaluating the given continuation.
If more than one element satisfies the condition then it depends on the
specific collection class which element will be returned.
returns the element that complies the condition or the result
of evaluating the continuation
count(predicate)
Collection.count(predicate)
Counts all elements of self collection that satisfies a given condition
The condition is a closure argument that takes a single element and
answers a number.
returns an integer number
occurrencesOf(element)
Collection.occurrencesOf(element)
Documentation not found
sum(closure)
Collection.sum(closure)
Collects the sum of each value for all elements.
This is similar to call a map {} to transform each element into a
number object and then adding all those numbers.
The condition is a closure argument that takes a single element and
answers a boolean value.
returns an integer
sum()
Collection.sum()
Documentation not found
map(closure)
Collection.map(closure)
Answers a new collection that contains the result of transforming
each of self collection's elements using a given closure.
The condition is a closure argument that takes a single element
and answers an object.
returns another list
flatMap(closure)
Collection.flatMap(closure)
Documentation not found
filter(closure)
Collection.filter(closure)
Documentation not found
contains(element)
Collection.contains(element)
Documentation not found
flatten()
Collection.flatten()
Documentation not found
toString()
Collection.toString()
Documentation not found
toStringPrefix()
Collection.toStringPrefix()
Documentation not found
toStringSuffix()
Collection.toStringSuffix()
Documentation not found
printString()
Collection.printString()
Documentation not found
asList()
Collection.asList()
Documentation not found
asSet()
Collection.asSet()
Documentation not found
copy()
Collection.copy()
Documentation not found
copyWithout(elementToRemove)
Collection.copyWithout(elementToRemove)
Documentation not found
copyWith(elementToAdd)
Collection.copyWith(elementToAdd)
Documentation not found
sortedBy(closure)
Collection.sortedBy(closure)
Documentation not found
newInstance()
Collection.newInstance()
Documentation not found
anyOne()
Collection.anyOne()
Documentation not found
add(element)
Collection.add(element)
Documentation not found
remove(element)
Collection.remove(element)
Documentation not found
fold(element, closure)
Collection.fold(element, closure)
Documentation not found
size()
Collection.size()
Documentation not found
clear()
Collection.clear()
Documentation not found
join(separator)
Collection.join(separator)
Documentation not found
join()
Collection.join()
Documentation not found
Singleton collection
Builder object for collections.
It compensates for the lack of vararg constructors.
Comportamiento
list(elements)
collection.list(elements)
Documentation not found
set(elements)
collection.set(elements)
Documentation not found
Class Set
A collection that contains no duplicate elements.
It models the mathematical set abstraction.
A Set guarantees no order of elements.
Note: Great care must be exercised if mutable objects are used as set elements.
The behavior of a set is not specified if the value of an object is changed in
a manner that affects equals comparisons while the object is an element in the set.
A special case of this prohibition is that it is not permissible for a set to contain
itself as an element.
since 1.3
Comportamiento
newInstance()
Set.newInstance()
Documentation not found
toStringPrefix()
Set.toStringPrefix()
Documentation not found
toStringSuffix()
Set.toStringSuffix()
Documentation not found
asList()
Set.asList()
Documentation not found
asSet()
Set.asSet()
Documentation not found
anyOne()
Set.anyOne()
Documentation not found
union(another)
Set.union(another)
Answers a new Set with the elements of both self and another collection.
intersection(another)
Set.intersection(another)
Documentation not found
difference(another)
Set.difference(another)
Answers a new Set with the elements of self that don't exist in another collection
fold(initialValue, closure)
Set.fold(initialValue, closure)
Reduce a collection to a certain value, beginning with a seed or initial value.
filter(closure)
Set.filter(closure)
Answers a new set with the elements meeting
a given condition. The condition is a closure argument that
takes a single element and answers a boolean.
max()
Set.max()
Answers the element that represents the maximum value in the collection.
The criteria is by direct comparison of the elements.
If set is empty, an ElementNotFound exception is thrown.
findOrElse(predicate, continuation)
Set.findOrElse(predicate, continuation)
Tries to find an element in a collection (based on a closure) or
applies a continuation closure.
add(element)
Set.add(element)
Adds the specified element to this set if it is not already present.
unsafeAdd(element)
Set.unsafeAdd(element)
private
remove(element)
Set.remove(element)
Removes the specified element from this set if it is present.
size()
Set.size()
Answers the number of elements in this set (its cardinality).
clear()
Set.clear()
Removes all of the elements from this set. This is a side effect operation.
join(separator)
Set.join(separator)
Answers the concatenated string representation of the elements in the given set.
You can pass an optional character as an element separator (default is ",")
join()
Set.join()
Answers the concatenated string representation of the elements in the given set
with default element separator (",")
contains(other)
Set.contains(other)
Answers whether this collection contains the specified element.
==(other)
Set.==(other)
Two sets are equals if they have the same elements, no matter
the order.
Class List
An ordered collection (also known as a sequence).
You iterate the list the same order elements are inserted.
The user can access elements by their integer index (position in the list).
A List can contain duplicate elements.
since 1.3
Comportamiento
get(index)
List.get(index)
Documentation not found
newInstance()
List.newInstance()
Creates a new list
anyOne()
List.anyOne()
Documentation not found
first()
List.first()
Documentation not found
head()
List.head()
Synonym for first method
last()
List.last()
Documentation not found
toStringPrefix()
List.toStringPrefix()
Documentation not found
toStringSuffix()
List.toStringSuffix()
Documentation not found
asList()
List.asList()
Documentation not found
asSet()
List.asSet()
Converts a collection to a set (removing duplicates if necessary)
subList(start)
List.subList(start)
Documentation not found
subList(start, end)
List.subList(start, end)
Documentation not found
sortBy(closure)
List.sortBy(closure)
Documentation not found
take(n)
List.take(n)
Takes first n elements of a list.
drop(n)
List.drop(n)
Documentation not found
reverse()
List.reverse()
Documentation not found
filter(closure)
List.filter(closure)
Answers a new list with the elements meeting
a given condition. The condition is a closure argument that
takes a single element and answers a boolean.
contains(obj)
List.contains(obj)
Answers whether this collection contains the specified element.
max()
List.max()
Answers the element that represents the maximum value in the collection.
The criteria is by direct comparison of the elements (they must be sortable).
If collection is empty, an ElementNotFound exception is thrown.
fold(initialValue, closure)
List.fold(initialValue, closure)
Reduce a collection to a certain value, beginning with a seed or initial value
findOrElse(predicate, continuation)
List.findOrElse(predicate, continuation)
Finds the first element matching the boolean closure,
or evaluates the continuation block closure if no element is found
add(element)
List.add(element)
Adds the specified element as last one
remove(element)
List.remove(element)
Removes an element in this list, if it is present.
size()
List.size()
Answers the number of elements
clear()
List.clear()
Removes all of the mappings from this Dictionary.
This is a side effect operation.
join(separator)
List.join(separator)
Answers the concatenated string representation of the elements in the given set.
You can pass an optional character as an element separator (default is ",")
join()
List.join()
Answers the concatenated string representation of the elements in the given set,
using default element separator (",")
==(other)
List.==(other)
A list is == another list if all elements are equal (defined by == message)
withoutDuplicates()
List.withoutDuplicates()
Answers the list without duplicate elements. Preserves order of elements.
[1, 3, 1, 5, 1, 3, 2, 5].withoutDuplicates() => Answers [1, 3, 5, 2]
[].withoutDuplicates() => Answers []
randomize()
List.randomize()
Shuffles the order of the elements in the list.
This is a side effect operation.
randomized()
List.randomized()
Documentation not found
Class Dictionary
Represents a set of key -> values
Comportamiento
initialize()
Dictionary.initialize()
Documentation not found
put(_key, _value)
Dictionary.put(_key, _value)
Adds or updates a value based on a key.
If key is not present, a new value is added.
If key is present, value is updated.
This is a side effect operation.
basicGet(_key)
Dictionary.basicGet(_key)
Answers the value to which the specified key is mapped,
or null if this Dictionary contains no mapping for the key.
getOrElse(_key, _closure)
Dictionary.getOrElse(_key, _closure)
Answers the value to which the specified key is mapped,
or evaluates a non-parameter closure otherwise.
get(_key)
Dictionary.get(_key)
Documentation not found
size()
Dictionary.size()
Answers the number of key-value mappings in this Dictionary.
isEmpty()
Dictionary.isEmpty()
Answers whether the dictionary has no elements
containsKey(_key)
Dictionary.containsKey(_key)
Documentation not found
containsValue(_value)
Dictionary.containsValue(_value)
Answers whether if this Dictionary maps one or more keys to the specified value.
remove(_key)
Dictionary.remove(_key)
Removes the mapping for a key from this Dictionary if it is present.
If key is not present nothing happens.
This is a side effect operation.
keys()
Dictionary.keys()
Answers a list of the keys contained in this Dictionary.
values()
Dictionary.values()
Answers a list of the values contained in this Dictionary.
forEach(closure)
Dictionary.forEach(closure)
Performs the given action for each entry in this Dictionary
until all entries have been processed or the action throws an exception.
Expected closure with two parameters: the first associated with key and
second with value.
clear()
Dictionary.clear()
Removes all of the mappings from this Dictionary.
This is a side effect operation.
toString()
Dictionary.toString()
String representation of a Dictionary
==(other)
Dictionary.==(other)
Documentation not found
Class Number
In Wollok we have numbers as an immutable representation. You can customize
how many decimals you want to work with, and printing strategies. So
number two could be printed as "2", "2,00000", "2,000", etc.
Coercing strategy for numbers can be
1) rounding up: 2,3258 using 3 decimals will result in 2,326
2) rounding down or truncation: 2,3258 using 3 decimals will
result in 2,325
3) not allowed: 2,3258 using 3 decimals will throw an exception
since decimals exceeds maximum allowed
(unification between Double and Integer in a single Number class)
since 1.3
noInstantiate
Comportamiento
coerceToInteger()
Number.coerceToInteger()
private
Applies coercing strategy to integer. If it is an integer, nothing happens.
Otherwise, if it is a decimal, defined coercing algorithm is applied
(see definition of class Number)
coerceToPositiveInteger()
Number.coerceToPositiveInteger()
private
see coerceToInteger
Applies coercing strategy to integer. And throws exception if it is negative.
===(other)
Number.===(other)
Two references are identical if they are the same number
+(other)
Number.+(other)
Documentation not found
-(other)
Number.-(other)
Documentation not found
*(other)
Number.*(other)
Documentation not found
/(other)
Number./(other)
Documentation not found
div(other)
Number.div(other)
Integer division between self and other
**(other)
Number.**(other)
Documentation not found
%(other)
Number.%(other)
Answers remainder of division between self and other
toString()
Number.toString()
String representation of self number
..(end)
Number...(end)
Builds a Range between self and end
>(other)
Number.>(other)
Documentation not found
<(other)
Number.<(other)
Documentation not found
>=(other)
Number.>=(other)
Documentation not found
<=(other)
Number.<=(other)
Documentation not found
abs()
Number.abs()
Documentation not found
invert()
Number.invert()
Inverts sign of self
max(other)
Number.max(other)
Answers the greater number between two
min(other)
Number.min(other)
Documentation not found
limitBetween(limitA, limitB)
Number.limitBetween(limitA, limitB)
Documentation not found
between(min, max)
Number.between(min, max)
Documentation not found
squareRoot()
Number.squareRoot()
Documentation not found
square()
Number.square()
Documentation not found
even()
Number.even()
Answers whether self is an even number
(divisible by 2, mathematically 2k).
Self must be an integer value
odd()
Number.odd()
Documentation not found
rem(other)
Number.rem(other)
Documentation not found
stringValue()
Number.stringValue()
Documentation not found
roundUp(_decimals)
Number.roundUp(_decimals)
Rounds up self up to a certain amount of decimals.
Amount of decimals must be a positive and integer value.
truncate(_decimals)
Number.truncate(_decimals)
Truncates self up to a certain amount of decimals.
Amount of decimals must be a positive and integer value.
randomUpTo(max)
Number.randomUpTo(max)
Answers a random number between self and max
roundUp()
Number.roundUp()
Answers the next integer greater than self
round()
Number.round()
Returns the value of a number rounded to the nearest integer.
gcd(other)
Number.gcd(other)
greater common divisor.
Both self and "other" parameter are coerced to be integer values.
lcm(other)
Number.lcm(other)
least common multiple.
Both self and "other" parameter are coerced to be integer values.
digits()
Number.digits()
Documentation not found
isInteger()
Number.isInteger()
Documentation not found
isPrime()
Number.isPrime()
Answers whether self is a prime number,
like 2, 3, 5, 7, 11 ...
Self must be an integer positive value
times(action)
Number.times(action)
Documentation not found
plus()
Number.plus()
Documentation not found
Class String
Strings are constant;
their values cannot be changed after they are created.
noInstantiate
Comportamiento
length()
String.length()
Answers the number of elements
charAt(index)
String.charAt(index)
Answers the char value at the specified index. An index ranges
from 0 to length() - 1. The first char value of the sequence is
at index 0, the next at index 1, and so on, as for array indexing.
Parameter index must be a positive integer value.
+(other)
String.+(other)
Documentation not found
concat(other)
String.concat(other)
Concatenates the specified string to the end of this string. Same as +.
startsWith(prefix)
String.startsWith(prefix)
Tests if this string starts with the specified prefix.
It is case sensitive.
endsWith(suffix)
String.endsWith(suffix)
Tests if this string ends with the specified suffix.
It is case sensitive.
see startsWith
indexOf(other)
String.indexOf(other)
Answers the index within this string of the first occurrence
of the specified character.
If character is not present, Answers -1
lastIndexOf(other)
String.lastIndexOf(other)
Answers the index within this string of the last
occurrence of the specified character.
If character is not present, Answers -1
toLowerCase()
String.toLowerCase()
Converts all of the characters in this String to lower case
toUpperCase()
String.toUpperCase()
Converts all of the characters in this String to upper case
trim()
String.trim()
Answers a string whose value is this string,
with any leading and trailing whitespace removed.
reverse()
String.reverse()
Answers a string reversing this string,
so that first character becomes last character of the new string and so on.
takeLeft(length)
String.takeLeft(length)
see take
takeRight(_length)
String.takeRight(_length)
Takes last n characters of this string.
n must be zero-positive integer.
<(aString)
String.<(aString)
Documentation not found
<=(aString)
String.<=(aString)
Documentation not found
>(aString)
String.>(aString)
Documentation not found
>=(aString)
String.>=(aString)
Documentation not found
contains(element)
String.contains(element)
Documentation not found
isEmpty()
String.isEmpty()
Answers whether this string has no characters
equalsIgnoreCase(aString)
String.equalsIgnoreCase(aString)
Documentation not found
substring(index)
String.substring(index)
Documentation not found
substring(startIndex, endIndex)
String.substring(startIndex, endIndex)
Answers a substring of this string beginning
from an inclusive index up to another inclusive index
split(expression)
String.split(expression)
Splits this string around matches of the given string.
Answers a list of strings.
replace(expression, replacement)
String.replace(expression, replacement)
Documentation not found
toString()
String.toString()
This object (which is already a string!) is itself returned
printString()
String.printString()
String implementation of printString,
simply adds quotation marks
==(other)
String.==(other)
Documentation not found
size()
String.size()
A synonym for length
take(n)
String.take(n)
Takes first n characters of this string.
n must be zero-positive integer.
drop(n)
String.drop(n)
Documentation not found
words()
String.words()
Documentation not found
capitalize()
String.capitalize()
Changes the first letter of every word to
upper case in this string.
Class Boolean
Represents a Boolean value (true or false)
noInstantiate
Comportamiento
and(other)
Boolean.and(other)
Answers the result of applying the logical AND operator
to the specified boolean operands self and other
&&(other)
Boolean.&&(other)
A synonym for and operation
or(other)
Boolean.or(other)
Answers the result of applying the logical OR operator
to the specified boolean operands self and other
||(other)
Boolean.||(other)
A synonym for or operation
toString()
Boolean.toString()
String representation of this boolean value.
==(other)
Boolean.==(other)
Compares this string to the specified object.
The result is true if and only if the
argument is not null and represents same value
(true or false)
negate()
Boolean.negate()
NOT logical operation
Class Range
Represents a finite arithmetic progression
of integer numbers with optional step
If start = 1, end = 8, Range will represent [1, 2, 3, 4, 5, 6, 7, 8]
If start = 1, end = 8, step = 3, Range will represent [1, 4, 7]
since 1.3
Estado
Atributo | WollokDoc |
---|---|
start | Documentation not found |
end | Documentation not found |
property step | Documentation not found |
Comportamiento
initialize()
Range.initialize()
Instantiates a Range.
Both start and end must be integer values.
start()
Range.start()
Documentation not found
end()
Range.end()
Documentation not found
step(_step)
Range.step(_step)
Documentation not found
forEach(closure)
Range.forEach(closure)
Documentation not found
map(closure)
Range.map(closure)
Answers a new collection that contains the result of
transforming each of self collection's elements using
a given closure.
The condition is a closure argument that takes an integer
and answers an object.
returns another list
flatMap(closure)
Range.flatMap(closure)
Documentation not found
asList()
Range.asList()
Documentation not found
isEmpty()
Range.isEmpty()
Documentation not found
fold(seed, foldClosure)
Range.fold(seed, foldClosure)
Documentation not found
size()
Range.size()
Answers the number of elements
any(closure)
Range.any(closure)
Documentation not found
all(closure)
Range.all(closure)
Answers whether all the elements of range satisfy a given
condition. The condition is a closure argument that takes a number
and answers a boolean value.
returns true/false
filter(closure)
Range.filter(closure)
Answers a new list with the elements meeting
a given condition. The condition is a closure argument that
takes a single element and answers a boolean.
min()
Range.min()
Answers the element that represents the minimum value in the range.
The criteria is by direct comparison of the elements (they must be sortable).
max()
Range.max()
Answers the element that represents the maximum value in the range.
anyOne()
Range.anyOne()
Answers a random integer contained in the range
contains(element)
Range.contains(element)
Tests whether a number is contained in the range
sum()
Range.sum()
Sums all elements in the collection.
returns a number
sum(closure)
Range.sum(closure)
Sums all elements that match the boolean closure
count(closure)
Range.count(closure)
Counts how many elements match the boolean closure
find(closure)
Range.find(closure)
Answers the number of the range that satisfies a given condition.
throws ElementNotFoundException if no element matched the given predicate
findOrElse(closure, continuation)
Range.findOrElse(closure, continuation)
Finds the first number matching the boolean closure,
or evaluates the continuation block closure if no element is found
findOrDefault(predicate, value)
Range.findOrDefault(predicate, value)
Answers the number of the range that satisfies a given condition,
or the given default otherwise, if no element matched the predicate.
sortedBy(closure)
Range.sortedBy(closure)
Answers a new List that contains the elements of self collection
sorted by a criteria given by a closure. The closure receives two objects
X and Y and answers a boolean, true if X should come before Y in the
resulting collection.
returns a new List
toString()
Range.toString()
String representation of this range object
Class Closure
Represents an executable piece of code. You can create a closure,
assign it to a reference, evaluate it many times,
send it as parameter to another object, and many useful things.
since 1.3
noInstantiate
Comportamiento
apply(parameters)
Closure.apply(parameters)
Evaluates this closure passing its parameters
toString()
Closure.toString()
String representation of this closure object
Singleton calendar
Utility object to contain Date and Date-related info, such as WKO and factory methods.
since 3.0.0
Estado
Atributo | WollokDoc |
---|---|
const property monday | Documentation not found |
const property tuesday | Documentation not found |
const property wednesday | Documentation not found |
const property thursday | Documentation not found |
const property friday | Documentation not found |
const property saturday | Documentation not found |
const property sunday | Documentation not found |
const property daysOfWeek | Documentation not found |
Comportamiento
today()
calendar.today()
Documentation not found
yesterday()
calendar.yesterday()
Documentation not found
tomorrow()
calendar.tomorrow()
Documentation not found
Class Date
Represents a Date (without time). A Date is immutable, once created you can not change it.
since 1.4.5
Estado
Atributo | WollokDoc |
---|---|
const property day | Documentation not found |
const property month | Documentation not found |
const property year | Documentation not found |
Comportamiento
toString()
Date.toString()
String representation of a date
==(_aDate)
Date.==(_aDate)
Two dates are equals if they represent the same date
plusDays(_days)
Date.plusDays(_days)
Answers a copy of this Date with the specified number of days added.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
plusMonths(_months)
Date.plusMonths(_months)
Answers a copy of this Date with the specified number of months added.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
plusYears(_years)
Date.plusYears(_years)
Answers a copy of this Date with the specified number of years added.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
isLeapYear()
Date.isLeapYear()
Checks if the year is a leap year, like 2000, 2004, 2008...
dayOfWeek()
Date.dayOfWeek()
Answers the day of the week of the Date with an object representation.
There is a wko (well known object) for every day of the week.
internalDayOfWeek()
Date.internalDayOfWeek()
Answers the day of week of the Date, where
1 = MONDAY
2 = TUESDAY
3 = WEDNESDAY
...
7 = SUNDAY
-(_aDate)
Date.-(_aDate)
Answers the difference in days between two dates, assuming self is minuend and _aDate is subtrahend.
minusDays(_days)
Date.minusDays(_days)
Answers a copy of this date with the specified number of days subtracted.
This instance is immutable and unaffected by this method call.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
minusMonths(_months)
Date.minusMonths(_months)
Answers a copy of this date with the specified number of months subtracted.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
minusYears(_years)
Date.minusYears(_years)
Answers a copy of this date with the specified number of years subtracted.
Parameter must be an integer value.
This operation has no side effect (a new date is returned).
<(_aDate)
Date.<(_aDate)
Documentation not found
>(_aDate)
Date.>(_aDate)
Documentation not found
<=(_aDate)
Date.<=(_aDate)
Documentation not found
>=(_aDate)
Date.>=(_aDate)
Documentation not found
between(_startDate, _endDate)
Date.between(_startDate, _endDate)
Documentation not found
shortDescription()
Date.shortDescription()
Documentation not found
isWorkDay()
Date.isWorkDay()
Answer whether the day is a work day (between monday and friday)
isWeekendDay()
Date.isWeekendDay()
Documentation not found
Singleton io
Represents an Input/Output event handler.
since 1.9.2
Estado
Atributo | WollokDoc |
---|---|
const property eventHandlers | // TODO: merge handlers |
const property timeHandlers | Documentation not found |
const property collitionHandlers | Documentation not found |
property eventQueue | Documentation not found |
property currentTime | Documentation not found |
property exceptionHandler | Documentation not found |
property domainExceptionHandler | Documentation not found |
Comportamiento
queueEvent(event)
io.queueEvent(event)
Documentation not found
eventHandlersFor(event)
io.eventHandlersFor(event)
Documentation not found
addEventHandler(event, callback)
io.addEventHandler(event, callback)
Documentation not found
removeEventHandler(event)
io.removeEventHandler(event)
Documentation not found
timeHandlers(name)
io.timeHandlers(name)
Documentation not found
containsTimeEvent(name)
io.containsTimeEvent(name)
Documentation not found
addTimeHandler(name, callback)
io.addTimeHandler(name, callback)
Documentation not found
removeTimeHandler(name)
io.removeTimeHandler(name)
Documentation not found
collitionHandlersFor(event)
io.collitionHandlersFor(event)
Documentation not found
addCollitionHandler(event, callback)
io.addCollitionHandler(event, callback)
Documentation not found
removeCollitionHandler(event)
io.removeCollitionHandler(event)
Documentation not found
clear()
io.clear()
Documentation not found
flushEvents(time)
io.flushEvents(time)
Documentation not found
runHandler(callback)
io.runHandler(callback)
Documentation not found
lib.wlk
Singleton console
Console is a global wollok object that implements a character-based console device
called "standard input/output" stream
Comportamiento
println(obj)
console.println(obj)
Prints a String with end-of-line character
readLine()
console.readLine()
Reads a line from input stream
readInt()
console.readInt()
Reads an int character from input stream
newline()
console.newline()
Returns the system's representation of a new line:
- \n in Unix systems
- \r\n in Windows systems
Class OtherValueExpectedException
Exception to handle other values expected in assert.throwsException... methods
Class AssertionException
Exception to handle difference between current and expected values
in assert.throwsException... methods
Estado
Atributo | WollokDoc |
---|---|
const property expected | Documentation not found |
const property actual | Documentation not found |
Singleton assert
Assert object simplifies testing conditions
Comportamiento
that(value)
assert.that(value)
Tests whether value is true. Otherwise throws an exception.
notThat(value)
assert.notThat(value)
Documentation not found
equals(expected, actual)
assert.equals(expected, actual)
Documentation not found
notEquals(expected, actual)
assert.notEquals(expected, actual)
Documentation not found
doesNotThrowException(block)
assert.doesNotThrowException(block)
Documentation not found
throwsException(block)
assert.throwsException(block)
Documentation not found
throwsExceptionLike(exceptionExpected, block)
assert.throwsExceptionLike(exceptionExpected, block)
Documentation not found
throwsExceptionWithMessage(errorMessage, block)
assert.throwsExceptionWithMessage(errorMessage, block)
Documentation not found
throwsExceptionWithType(exceptionExpected, block)
assert.throwsExceptionWithType(exceptionExpected, block)
Documentation not found
throwsExceptionByComparing(block, comparison)
assert.throwsExceptionByComparing(block, comparison)
Documentation not found
fail(message)
assert.fail(message)
Documentation not found
equals(value)
assert.equals(value)
Documentation not found
Class StringPrinter
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
buffer | Documentation not found |
Comportamiento
println(obj)
StringPrinter.println(obj)
Documentation not found
getBuffer()
StringPrinter.getBuffer()
Documentation not found
game.wlk
Singleton game
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
const visuals | Collection of visual objects in the game |
property running | Documentation not found |
property errorReporter | Allows to configure a visual component as "error reporter". Then every error in game board will be reported by this visual component, in a balloon message form. |
Comportamiento
initialize()
game.initialize()
Documentation not found
addVisual(positionable)
game.addVisual(positionable)
Documentation not found
addVisualCharacter(visual)
game.addVisualCharacter(visual)
Adds an object to the board for drawing it. It can be moved with arrow keys.
That object should understand a position property
(implemented by a reference or getter method).
removeVisual(visual)
game.removeVisual(visual)
Documentation not found
hasVisual(visual)
game.hasVisual(visual)
Verifies if an object is currently in the board.
allVisuals()
game.allVisuals()
Returns all visual objects added to the board.
whenKeyPressedDo(event, action)
game.whenKeyPressedDo(event, action)
Adds a block that will be executed each time a specific key is pressed
see keyboard.onPressDo()
whenCollideDo(visual, action)
game.whenCollideDo(visual, action)
Documentation not found
onCollideDo(visual, action)
game.onCollideDo(visual, action)
Documentation not found
onTick(milliseconds, name, action)
game.onTick(milliseconds, name, action)
Documentation not found
schedule(milliseconds, action)
game.schedule(milliseconds, action)
Documentation not found
removeTickEvent(event)
game.removeTickEvent(event)
Documentation not found
onSameCell(position1, position2)
game.onSameCell(position1, position2)
Documentation not found
getObjectsIn(position)
game.getObjectsIn(position)
Returns all objects in given position.
say(visual, message)
game.say(visual, message)
Draws a dialog balloon with given message in given visual object position.
clear()
game.clear()
Removes all visual objects in game and configurations (colliders, keys, etc).
colliders(visual)
game.colliders(visual)
Documentation not found
currentTime()
game.currentTime()
Returns the current Tick.
flushEvents(time)
game.flushEvents(time)
Runs all time event for the given time.
uniqueCollider(visual)
game.uniqueCollider(visual)
Documentation not found
stop()
game.stop()
Stops render the board and finish the game.
start()
game.start()
Documentation not found
at(x, y)
game.at(x, y)
Documentation not found
origin()
game.origin()
Documentation not found
center()
game.center()
Returns the center board position (rounded down).
title(title)
game.title(title)
Sets game title.
title()
game.title()
Returns game title.
width(width)
game.width(width)
Sets board width (in cells).
width()
game.width()
Returns board width (in cells).
height(height)
game.height(height)
Sets board height (in cells).
height()
game.height()
Returns board height (in cells).
ground(image)
game.ground(image)
Sets cells background image.
cellSize(size)
game.cellSize(size)
Sets cells size.
doCellSize(size)
game.doCellSize(size)
Documentation not found
boardGround(image)
game.boardGround(image)
Sets full background image.
hideAttributes(visual)
game.hideAttributes(visual)
Attributes will not show when user mouse over a visual component.
Default behavior is to show them.
showAttributes(visual)
game.showAttributes(visual)
Attributes will appear again when user mouse over a visual component.
Default behavior is to show them, so this is not necessary.
sound(audioFile)
game.sound(audioFile)
Returns a sound object. Audio file must be a .mp3, .ogg or .wav file.
tick(interval, action, execInmediately)
game.tick(interval, action, execInmediately)
Documentation not found
Class AbstractPosition
Documentation not found
Comportamiento
x()
AbstractPosition.x()
Documentation not found
y()
AbstractPosition.y()
Documentation not found
createPosition(x, y)
AbstractPosition.createPosition(x, y)
Documentation not found
right(n)
AbstractPosition.right(n)
Documentation not found
left(n)
AbstractPosition.left(n)
Returns a new Position n steps left from this one.
up(n)
AbstractPosition.up(n)
Returns a new Position n steps up from this one.
down(n)
AbstractPosition.down(n)
Returns a new Position, n steps down from this one.
say(element, message)
AbstractPosition.say(element, message)
Draw a dialog balloon with given message in given visual object position.
allElements()
AbstractPosition.allElements()
Documentation not found
clone()
AbstractPosition.clone()
//TODO: Implement native
distance(position)
AbstractPosition.distance(position)
Returns the distance between given position and self.
clear()
AbstractPosition.clear()
Documentation not found
==(other)
AbstractPosition.==(other)
Documentation not found
toString()
AbstractPosition.toString()
String representation of a position
round()
AbstractPosition.round()
Returns a new position with its coordinates rounded
Class Position
Represents a position in a two-dimensional gameboard.
It is an immutable object since Wollok 1.8.0
Estado
Atributo | WollokDoc |
---|---|
const x | Documentation not found |
const y | Documentation not found |
Comportamiento
x()
Position.x()
Documentation not found
y()
Position.y()
Documentation not found
createPosition(_x, _y)
Position.createPosition(_x, _y)
Documentation not found
Class MutablePosition
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
x | Documentation not found |
y | Documentation not found |
Comportamiento
x()
MutablePosition.x()
Documentation not found
y()
MutablePosition.y()
Documentation not found
createPosition(_x, _y)
MutablePosition.createPosition(_x, _y)
Documentation not found
goRight(n)
MutablePosition.goRight(n)
Documentation not found
goLeft(n)
MutablePosition.goLeft(n)
Documentation not found
goUp(n)
MutablePosition.goUp(n)
Documentation not found
goDown(n)
MutablePosition.goDown(n)
Documentation not found
Singleton keyboard
Keyboard object handles all keys movements. There is a method for each key.
Comportamiento
any()
keyboard.any()
Documentation not found
num(n)
keyboard.num(n)
Documentation not found
letter(l)
keyboard.letter(l)
Documentation not found
arrow(a)
keyboard.arrow(a)
Documentation not found
num0()
keyboard.num0()
Documentation not found
num1()
keyboard.num1()
Documentation not found
num2()
keyboard.num2()
Documentation not found
num3()
keyboard.num3()
Documentation not found
num4()
keyboard.num4()
Documentation not found
num5()
keyboard.num5()
Documentation not found
num6()
keyboard.num6()
Documentation not found
num7()
keyboard.num7()
Documentation not found
num8()
keyboard.num8()
Documentation not found
num9()
keyboard.num9()
Documentation not found
a()
keyboard.a()
Documentation not found
b()
keyboard.b()
Documentation not found
c()
keyboard.c()
Documentation not found
d()
keyboard.d()
Documentation not found
e()
keyboard.e()
Documentation not found
f()
keyboard.f()
Documentation not found
g()
keyboard.g()
Documentation not found
h()
keyboard.h()
Documentation not found
i()
keyboard.i()
Documentation not found
j()
keyboard.j()
Documentation not found
k()
keyboard.k()
Documentation not found
l()
keyboard.l()
Documentation not found
m()
keyboard.m()
Documentation not found
n()
keyboard.n()
Documentation not found
o()
keyboard.o()
Documentation not found
p()
keyboard.p()
Documentation not found
q()
keyboard.q()
Documentation not found
r()
keyboard.r()
Documentation not found
s()
keyboard.s()
Documentation not found
t()
keyboard.t()
Documentation not found
u()
keyboard.u()
Documentation not found
v()
keyboard.v()
Documentation not found
w()
keyboard.w()
Documentation not found
x()
keyboard.x()
Documentation not found
y()
keyboard.y()
Documentation not found
z()
keyboard.z()
Documentation not found
alt()
keyboard.alt()
Documentation not found
backspace()
keyboard.backspace()
Documentation not found
control()
keyboard.control()
Documentation not found
del()
keyboard.del()
Documentation not found
center()
keyboard.center()
Documentation not found
down()
keyboard.down()
Documentation not found
left()
keyboard.left()
Documentation not found
right()
keyboard.right()
Documentation not found
up()
keyboard.up()
Documentation not found
enter()
keyboard.enter()
Documentation not found
minusKey()
keyboard.minusKey()
Documentation not found
plusKey()
keyboard.plusKey()
Documentation not found
shift()
keyboard.shift()
Documentation not found
slash()
keyboard.slash()
Documentation not found
space()
keyboard.space()
Documentation not found
Class Key
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
const property keyCodes | Documentation not found |
Comportamiento
onPressDo(action)
Key.onPressDo(action)
Documentation not found
Class Sound
Wollok Game Sound object
Estado
Atributo | WollokDoc |
---|---|
const property file | Documentation not found |
Comportamiento
initialize()
Sound.initialize()
Documentation not found
play()
Sound.play()
Documentation not found
played()
Sound.played()
Answers whether the sound has been played or not.
stop()
Sound.stop()
Stops playing the sound and disposes resources.
pause()
Sound.pause()
Pauses the sound.
Throws error if the sound is already paused or if the sound hasn't been played yet.
resume()
Sound.resume()
Resumes playing the sound.
Throws error if the sound is not paused.
paused()
Sound.paused()
Answers whether the sound is paused or not.
volume(newVolume)
Sound.volume(newVolume)
Changes absolute volume, values must be between 0 and 1.
volume()
Sound.volume()
Answers the volume of the sound.
shouldLoop(looping)
Sound.shouldLoop(looping)
Sets whether the sound should loop or not.
shouldLoop()
Sound.shouldLoop()
Answers whether the sound is set to loop or not.
Class Tick
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
interval | Milliseconds to wait between each action |
const name | Documentation not found |
const action | Block to execute after each interval time lapse |
const inmediate | Documentation not found |
Comportamiento
start()
Tick.start()
Starts looping the action passed in to the tick
object when it was instantiated.
stop()
Tick.stop()
Documentation not found
reset()
Tick.reset()
Documentation not found
interval(milliseconds)
Tick.interval(milliseconds)
Documentation not found
isRunning()
Tick.isRunning()
Documentation not found
mirror.wlk
Class InstanceVariableMirror
Documentation not found
Estado
Atributo | WollokDoc |
---|---|
const target | Documentation not found |
const property name | Documentation not found |
Comportamiento
value()
InstanceVariableMirror.value()
Documentation not found
valueToString()
InstanceVariableMirror.valueToString()
Documentation not found
toString()
InstanceVariableMirror.toString()
Documentation not found
Class ObjectMirror
Represents an object capable of give information of another object.
It offers a reflection mechanism that is completely decoupled
from the object whose structure is being introspected.
Estado
Atributo | WollokDoc |
---|---|
const property target | Documentation not found |
Comportamiento
resolve(attributeName)
ObjectMirror.resolve(attributeName)
Documentation not found
instanceVariableFor(name)
ObjectMirror.instanceVariableFor(name)
Retrieves a specific variable for target object. Expects a name
instanceVariables()
ObjectMirror.instanceVariables()
Answers a list of instance variables for target object
vm.wlk
Singleton runtime
Object for Wollok implementation for runtime decisions
Comportamiento
isInteractive()
runtime.isInteractive()
true if running REPL, false otherwise