As Flambino points out, the method is very problematic for negative integers.
You need to either change the function to only accept unsigned integers or come up with some solution that makes sense for negative numbers.
In general though, I don't particularly like operator-overloading. Using functions/methods means there's some plain-English name to the operation you're performing that will give me some sort of hint at what the operation does so I don't have to guess.
As someone coming from an Objective-C/Foundation background (which will likely be most Swift programmers) and having zero Ruby experience, I could maybe guess at what the first one does:
println("Andrew rules! " * 42)
But as for the second one?
println("Andrew rules! " ** 42)
I'd have absolutely no clue. And I doubt I'd be the only one.
The amount of time you save typing **
instead of a more descriptive function name (which the IDE will autocomplete for you meaning the amount of time is basically the same either way) is definitely not worth the amount of time that other programmers behind you take to go figure out what this does:
let myVar = "Hello world!" ** 27
There's not even the slightest hint as to what this returns, and there's no descriptive function name to give any clues... so now I have to go hunt down where ever you've put the operator overload function for a string/int.
join("", Array<String>(count: right, repeatedValue: left))
\$\endgroup\$*
operator is that it won't complain about receiving a negative multiplier. Change to aUInt
maybe? (I have ~10 minutes experience with Swift so far, so I'm partly guessing) \$\endgroup\$"Andrew Rules" * 0
return an empty string? Ruby's does. Since you're mimicking that operator, so should yours. \$\endgroup\$