Skip to main content
Commonmark migration
Source Link

#Strings and ints are equal types

Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

4 5+
"4""5"+

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

12345û50000-

This would result into: 123404321.

#Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

4 5+
"4""5"+

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

12345û50000-

This would result into: 123404321.

Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

4 5+
"4""5"+

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

12345û50000-

This would result into: 123404321.

Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246

#Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

4 5+
"4""5"+

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

12345û50000-

This would result into: 123404321.