Skip to content

Untie These Chains – A Riddle

Here’s a riddle for you!

Suppose you are in the habit of using “function chaining” like this to reduce your lines of code:

path2 = path2.mid(2).left(path2.len()-1)

If so, be careful as they can sometimes surprise you with the results you get. Consider  the following code:

dim path1 as string = """C:\users\ieuser\desktop\new folder"""
path1 = path1.mid(2)
path1 = path1.left(path1.len()-1)
 
dim path2 as string = """C:\users\ieuser\desktop\new folder"""
path2 = path2.mid(2).left(path2.len()-1)

break

These two look a lot alike but do not give you the same result. Share your thoughts as to why this happens in the comments or go right to the solution.