0

How Nim's way assign variable in or beside other expression at once, the one that'd always led to:

 Error: expression 's = "foo"' has no type (or is ambiguous)

when trying like c/c++ code if (s = "foo").len > 5 { cout<< "Yes" ;} or some else?
the point was that, how to have variable assignment in some expressions at once,

itil memek cantik
  • 1,167
  • 2
  • 11

1 Answers1

3
if (let s = "foo"; s).len > 5:
  echo "Yes"

or

var s: string
if (s = "foo"; s).len > 5:
  echo "Yes"
ynfle
  • 171
  • 1
  • 3