Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Know your Trues and Falses

Each language sees "true" and "false" in a slightly different way. If they have similar syntax, you can exploit this by adding a decision that the languages will handle differently.

One exampleOne example from the Trick or Treat thread uses '', an empty string. In Lua, this evaluates to truthy, but falsy in Python, so the following:

print(''and'trick'or'treat') 

..will print a different string in each language.

All it takes is finding a value like this. For example, you could use '0', which evaluates to false in PHP but true in Python.

Know your Trues and Falses

Each language sees "true" and "false" in a slightly different way. If they have similar syntax, you can exploit this by adding a decision that the languages will handle differently.

One example from the Trick or Treat thread uses '', an empty string. In Lua, this evaluates to truthy, but falsy in Python, so the following:

print(''and'trick'or'treat') 

..will print a different string in each language.

All it takes is finding a value like this. For example, you could use '0', which evaluates to false in PHP but true in Python.

Know your Trues and Falses

Each language sees "true" and "false" in a slightly different way. If they have similar syntax, you can exploit this by adding a decision that the languages will handle differently.

One example from the Trick or Treat thread uses '', an empty string. In Lua, this evaluates to truthy, but falsy in Python, so the following:

print(''and'trick'or'treat') 

..will print a different string in each language.

All it takes is finding a value like this. For example, you could use '0', which evaluates to false in PHP but true in Python.

Source Link
FlipTack
  • 14.7k
  • 3
  • 56
  • 102

Know your Trues and Falses

Each language sees "true" and "false" in a slightly different way. If they have similar syntax, you can exploit this by adding a decision that the languages will handle differently.

One example from the Trick or Treat thread uses '', an empty string. In Lua, this evaluates to truthy, but falsy in Python, so the following:

print(''and'trick'or'treat') 

..will print a different string in each language.

All it takes is finding a value like this. For example, you could use '0', which evaluates to false in PHP but true in Python.