I think integer division would be a helpful addition to our set of custom operators
Just like in python,
//infix operator divides and rounds down to the nearest integer
Create a custom infix division operator if one side is a FloatingPoint. Eg
7 // 2 => output is 3
-7 // 2 => output is -4
infix operator //=> Expected operator name in operator declaration
@cHaLkdusT Thank you for opening this :)
I think this would only make sense if one of the sides is a FloatingPoint, because Int/Int division already works like that...
Looks like someone's forgetting his Swift basics 馃槄 I'll update the thread. Thanks @LucianoPAlmeida!
Also, It maybe will have to be another thing different than //, I'm not sure but I think the parser will think that it is a comment block :)
In python this works because the comment is #
I was thinking of a double 鉃椻灄 (emoji) character as an alternate, I'm not sure though if it makes sense.
I was thinking of a double 鉃椻灄 (emoji) character as an alternate, I'm not sure though if it makes sense.
Not sure, seems a bit weird to me TBH, but I don't have any suggestion either ...
BTW, in Swift, this expression -7 / 2 results to -3
Since the // operator in Python divides and rounds down to the nearest integer, this expression -7 // 2 must be -4
Yeah, but note that the behavior is the same two integer division return an integer rounded (to nearest or not) the behavior is that it returns a rounded integer :)
I don't think it is possible with // operator, because it is reserved for comments
Closing due to inactivity, feel free to reopen if you think this still worth a discussion 馃憤
Most helpful comment
Also, It maybe will have to be another thing different than
//, I'm not sure but I think the parser will think that it is a comment block :)In python this works because the comment is #