Reputation: 11
'tactic' <= 'tree'
Can i know why 'tactic' is lexicographically smaller than 'tree' / why will it return true for the code 'tactic'<='tree' ?
From my understanding , isn't it supposed to return false since the third index of both strings , where it's supposed to be ( t is > than e ) ? Hence returning a false ?
Upvotes: 0
Views: 261
Reputation: 109
The reason for this behavior is that the lexicographic order is computed from front to back. The first charater that is different defines the order of the items.
In your example it is evaluated this way:
Upvotes: 1