robotframework-style-guide icon indicating copy to clipboard operation
robotframework-style-guide copied to clipboard

Evaluation Namespace - $var vs '${var}'

Open manykarim opened this issue 2 years ago • 2 comments

Will you also touch topics like the Evaluation Namespace, e.g. in IF conditions?

e.g. When to use '${x}' == 'expected' or $x == 'expected'

manykarim avatar Oct 27 '23 13:10 manykarim

I guess that in such expressions the $x == 'expected' syntax should be used, as it preserves types and allows you to strictly use values as such.

Maybe it is not as error-prone as converting everything to str (as is done when using quotation marks) but it forces you to think in advance about types of variables you use, compare and evaluate. Also, it feels more natural (sorry for non-technical description) to use this syntax as $x is anyway evaluated by Python, so it is more straightforward to use python-like object than to convert everything in advance to string and then evaluate.

But of course It’s only an opinion and I’m not even a contributor to this repo at this point. Just found out about it and looked through „Issues” tab.

borutzki avatar Nov 25 '23 13:11 borutzki

Sounds like a good idea to add this, but it needs some good discussion on what the proper usage would be and what the differences would be.

guidodemmenie avatar Oct 15 '24 14:10 guidodemmenie