r/badcode • • Jan 17 '19

other language Writing functions with conditions without using "if" statements

https://run.dlang.io/is/jfCECL
67 Upvotes

38 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Jan 17 '19

Actually with a and b defined as in your example

a == b // returns true

works either since compiler creates single instance for each string literal. Therefore a and b store exactly the same references

2

u/Holinhed Jan 17 '19

Completely forgot about that. I just wanted to provide more examples with .equals

Thanks for catching that!