Try this.
protocol Position {
var x: Double { get set }
}
struct Car: Position {
var x: Double
}
func move(item: inout T) where T:Position {
item.x += 1
}
var car = Car(x: 50)
move(item: &car)
car.x // 51
Zhaoxin
On Sat, May 27, 2017 at 12:35 AM, Guillaume Lessard vi
In your example, the compiler needs a parameter of type Position. Car is a type
of Position, but they are not interchangeable. See below:
> On May 26, 2017, at 00:33, Седых Александр via swift-users
> wrote:
>
> protocol Position {
> var x: Double { getset }
> }
>
> struct Car: Position
> On 26 May 2017, at 11:01, Antonino Ficarra via swift-users
> wrote:
>
> - Why Swift continues to not support Float80 math functions?
> Example:
>
> print("\( log( Float( 1.0 ) ) )")
> print("\( log( Double( 1.0 ) ) )")
> // print("\( log( Float80( 1.0 ) ) )")// don’t compile and logl
- Why Swift continues to not support Float80 math functions?
Example:
print("\( log( Float( 1.0 ) ) )")
print("\( log( Double( 1.0 ) ) )")
// print("\( log( Float80( 1.0 ) ) )") // don’t compile and logl is unavailable
- Why min and max continue to not act like fmin and fmax (IEEE 754 standard)?
- Why Swift continues to not support Float80 math functions?
Example:
print("\( log( Float( 1.0 ) ) )")
print("\( log( Double( 1.0 ) ) )")
// print("\( log( Float80( 1.0 ) ) )") // don’t compile and logl is unavailable
- Why min and max continue to not act like fmin and fmax (IEEE 754 standard)?