Replies: 1 comment
-
Found the error in the copyinit for MyInt ... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This might be a silly question but I can't make the following code work in the playground, I get errors as below.
#- error: Expression [52]:43:22: invalid call to 'copyinit': argument #1 cannot be converted from 'MyInt' to 'Int'
#- self.first = first
#- ^~~~~
#-
#- Expression [52]:33:5: function declared here
#- fn copyinit(inout self, other: Int):
#- ^
#-
#- error: Expression [52]:44:23: invalid call to 'copyinit': argument #1 cannot be converted from 'MyInt' to 'Int'
#- self.second = second
#- ^~~~~~
#-
#- Expression [52]:33:5: function declared here
#- fn copyinit(inout self, other: Int):
#- ^
struct MyInt:
var value: Int
struct MyPair:
var first: MyInt
var second: MyInt
fn copyinit(inout self, other: MyPair):
self.first.value = other.first.value
self.second.value = other.second.value
def pairTest() -> Bool:
if (pairTest()):
print("Success")
else:
print("Not success")
Beta Was this translation helpful? Give feedback.
All reactions