[Phix] ? operator; string behavior
- Posted by _tom (admin) Oct 31, 2017
- 1360 views
In Phix, the ability of question_mark ? being able to output text and numbers is really handy:
Statement | Phix output | OE output |
---|---|---|
? 'A' | 65 | 65 |
? 'A' + 32 | 97 | 97 |
? 'A' & 'a' | "Aa" | {65,97} |
? 65 & 97 | "Aa" | {65,97} |
? 65 | 65 | 65 |
? {65} | {65} | {65} |
? "A" | "A" | {65} |
? "A" + 32 | "a" | 97 |
? {65} + 32 | {97} | {97} |
? 65 + 32 | 97 | 97 |
? 65 & 97 | "Aa" | {65,97} |
In Phix, single_quote ' delimiters sometimes make a number and sometimes a character. Any sometimes syntax is disturbing.
Phix
object x = { 'h','e','l','l','o' } ? x puts(1, x) printf(1, "%s", {x} ) /* {104,101,108,108,111} ello?helloPress any key... */
- The 'h' is not output using the ? operator.
- And, where does the extra '?' come from?
_tom