Merge branch 'master' of https://github.com/Tass/Nimrod into Tass-master
This commit is contained in:
commit
368bb3b5e2
2 changed files with 16 additions and 1 deletions
|
|
@ -1299,6 +1299,22 @@ algorithm returns true:
|
|||
if b.kind == distinct and typeEquals(b.baseType, a): return true
|
||||
return false
|
||||
|
||||
You can, however, define your own implicit converters:
|
||||
|
||||
.. code-block:: nimrod
|
||||
converter toInt(x: char): int = result = ord(x)
|
||||
|
||||
var
|
||||
x: int
|
||||
chr: char = 'a'
|
||||
|
||||
# implicit conversion magic happens here
|
||||
x = chr
|
||||
echo x # => 97
|
||||
# you can use the explicit form too
|
||||
x = chr.toInt
|
||||
echo x # => 97
|
||||
|
||||
|
||||
Assignment compatibility
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue