What does <~~ mean in swift?

  • A+

While checking a parser of a JSON in swift, I found the following code:

description = "desc" <~~ json 

I suppose that it is similar to use the following:

description = json["desc"] 

Is it correct? if no, what does this operator mean?



You are right. But it would be wrong to assume that's what it is set out to do in Swift.

I think the parser that was being used was Gloss, and it seems that they have written an operator overload specifically to mean description = json["desc"] (and or or some other stuff under the hood to make the parsing easier) . The operator does not have a meaning per se in Swift. But it's invented by the framework to do the parsing.

You can read about operator overloading here


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: