Skip to content

Instantly share code, notes, and snippets.

@Yardanico

Yardanico/gg.nim Secret

Last active July 31, 2020 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yardanico/a4cee9628999e7ef1d0068e343f18350 to your computer and use it in GitHub Desktop.
Save Yardanico/a4cee9628999e7ef1d0068e343f18350 to your computer and use it in GitHub Desktop.
type
Maybe = object
value: string
proc charmatch(input: string): Maybe =
# If you replace this line with just input
# or something else - it works.
result.value = input[0 .. ^1]
proc p1(): Maybe =
let lresult = charmatch("123;")
# The line below is needed - if you use var/let directly in
# lvalue, lnext assignment - it works.
var lvalue, lnext: string
(lvalue, lnext) = (lresult.value, ";")
result.value = lvalue
proc main =
let r1 = p1()
doAssert r1.value == "123;"
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment