Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just include this somewhere in your codebase. Maybe I'll make this more robust.

postfix operator ++{}

postfix func ++(lhs:Int) -> Int { return lhs + 1 }



That implementation is wrong in multiple ways. First of all, it should return the pre-increment value. Second, it doesn't actually increment your variable (you need to use an `inout` parameter for that).

Perhaps this demonstrates perfectly why it's being removed!


Yes, indeed. I wrote this somewhat as a joke, and I hope nobody would actually do this in production.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: