valeriyvan
(Valeriy Van)
1
The first snippet in Protocol Extensions chapter of Swift Language Guide doesn't compile.
import Foundation
extension RandomNumberGenerator {
func randomBool() -> Bool {
return random() > 0.5 // Binary operator '>' cannot be applied to operands of type 'Int' and 'Double'
}
}
Should I bug report this?
krilnon
(Kyle Murray)
2
Yeah, go ahead and file on Feedback Assistant and it'll get to the right place.
I think the specific issue is that this chapter has an example protocol that predates the standard library's RandomNumberGenerator protocol, so there's a name conflict. Earlier in the chapter, it defines:
protocol RandomNumberGenerator {
func random() -> Double
}
3 Likes
Karl
(👑🦆)
3