[swift-users] Why inout protocol parameter in function work with strange

Седых Александр se-a at mail.ru
Fri May 26 01:33:54 CDT 2017

Hello. I have protocol witch allow type to handle it's position and function who handle this position and compiler get me error. Please, tell, Why I can not use protocol name in inout function? The example here.

protocol Position {
     var x:  Double {  get set }
struct Car:  Position {
     var x:  Double
func move(item:  inout  Position ) {
    item. x +=  1
var car =  Car (x:  50 )
move (item: & car ) \\  cannot pass immutable value as inout argument: implicit conversion from 'Car' to 'Position' requires a temporary

Седых Александр
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170526/fc404dbd/attachment.html>

More information about the swift-users mailing list