Replies: 1 comment
-
Until mojo has traits, there isn't a clean implementation of The easiest thing (until traits and classes) is to manually convert to the string representation you want e.g. |
Beta Was this translation helpful? Give feedback.
-
In the following experiment on the playground I am getting errors. I added a str method to MyInt but doesn't solve the problem. Wondering what the definition of string is in Mojo.
Errors:
error: Expression [24]:70:10: no matching function in call to 'print':
print(z.second)
~~~~~^~~~~~~~~~
/.modular/Kernels/mojo/Stdlib/IO.mojo:274:1: candidate not viable: callee expects 0 arguments, but 1 was specified
fn print():
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:279:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'DType'
fn print(t: DType):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:288:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'String'
fn print(x: String):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:298:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'StringRef'
fn print(x: StringRef):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:308:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'StringLiteral'
fn print(x: StringLiteral):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:317:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'Bool'
fn print(x: Bool):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:326:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'FloatLiteral'
fn print(x: FloatLiteral):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:335:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'Int'
fn print(x: Int):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:344:1: candidate not viable: callee expects 2 input parameters but 0 were provided
fn print[
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:369:1: candidate not viable: callee expects 1 input parameter but 0 were provided
fn print[type: DType](x: Atomic[type]):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:382:1: candidate not viable: callee expects 1 input parameter but 0 were provided
fn print[length: Int](shape: DimList):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:408:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to 'object'
fn print(obj: object):
^
/.modular/Kernels/mojo/Stdlib/IO.mojo:427:1: candidate not viable: argument #0 cannot be converted from 'MyInt' to '_Printable'
fn print(*elements: _Printable):
^
Beta Was this translation helpful? Give feedback.
All reactions