fix #15, default toString for a class
+default comparison for a class !give up struct in favor of class (simpler)
This commit is contained in:
1 parent
2a93e6f7da
commit
652e1d3af4
4 files changed
+67
-5
No files matched your search
+17
@@ -141,7 +141,24 @@ set at construction but not available outside the class:
|
||||
void
|
||||
>>> void
|
||||
|
||||
## Default class methods
|
||||
|
||||
In many cases it is necessary to implement custom comparison and `toString`, still
|
||||
each class is provided with default implementations:
|
||||
|
||||
- default toString outputs class name and its _public_ fields.
|
||||
- default comparison compares compares all public fields in order of appearance.
|
||||
|
||||
For example, for our class Point:
|
||||
|
||||
class Point(x,y)
|
||||
assert( Point(1,2) == Point(1,2) )
|
||||
assert( Point(1,2) !== Point(1,2) )
|
||||
assert( Point(1,2) != Point(1,3) )
|
||||
assert( Point(1,2) < Point(2,2) )
|
||||
assert( Point(1,2) < Point(1,3) )
|
||||
Point(1,1+1)
|
||||
>>> Point(1, 2)
|
||||
|
||||
# Theory
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Declaring arguments in Lyng
|
||||
|
||||
It is a common thing that occurs in many places in Lyng, function declarations,
|
||||
lambdas, struct and class declarations.
|
||||
lambdas and class declarations.
|
||||
|
||||
## Regular
|
||||
|
||||
|
||||
Reference in new issue
Block a user