Nim: How to import variable declared in another file

4191 views nim

I have a variable defined in a file like

# one.nim
let someVar = SomeClass()

I want to be able to use this variable in another file as something like:

# two.nim
let _ = someVar.method()

what changes do I need to make something like this happen?

answered question

1 Answer


just making the variable exportable by appending a * will make someVar importable.

# one.nim
let someVar* = SomeClass()

posted this

Have an answer?


Please login first before posting an answer.