func reverse(first:inout Int,second:inout Int) {
let tmp=first
first=second
second=tmp
}
var nums=[1,2,5,3,6]
reverse(first:&nums[2],second:&nums[4])
The error I get is “E(207) Only fields or local variables can be passed as ‘var’ or ‘out’ for paramter ‘1’”.
UPDATE: IGNORE BELOW, BUG DOES NOT EXIST
The above is when compiling against .NET.
When compiling against Island, type inference doesn’t seem to work and the following needs to be done:
var nums:[Int]=[1,2,5,3,6]
Otherwise, the error: “E(597) Value passed for parameter 1 is nullable but must be not null in call to func MyProgram.reverse(# ref first: Int, # ref second: Int)” is shown.
Sounds as designed — a pass-by-reference parameter by definition needs to be a memory location. nums is a collection class with an indexed (subscript in Swift parlance) property — essentially that involves a method call to read and write the value. That cannot possibly be passed “by reference”.
Sounds as designed — a pass-by-reference parameter by definition
needs to be a memory location. nums is a collection class with an
indexed (subscript in Swift parlance) property — essentially that
involves a method call to read and write the value. That cannot
possibly be passed “by reference”.
Right… I tried in repl.it and it works there too though…
Sorry, I confused the error message for an earlier build with a successful one. For some reason, VS 2015 doesn’t clear the Error List on a successful build.
Ok, this seems to be happening when using the Island Console Application (Windows) solution template (it doesn’t happen with the .NET Console Application template). CTRL-SHIFT-B to build the code below:
func reverse(first:inout Int,second:inout Int) {
let tmp=first
first=second
second=tmp
}
var nums=[1,2,5,3,6]
reverse(first:&nums[2],second:&nums[4])
print()
After it complains about the line with reverse(), comment out that line and do a CTRL-SHIFT-B, the build will complete successfully but the Error List is not cleared. This is under Visual Studio 2015 Community Edition Update 3.
in the Error List. Fix this by going to Main.Designer.swift and remove line 27 (self.pictureBox1.Image = ...) and you will build successfully, but the items in the Error List remain.
This is under Visual Studio 2015 Community Edition, Elements 10.0.0.2311
Can you post the latest version “RemObjects Elements with Water - 10.0.0.2319” to my personal downloads “jbperez808” so I can do more testing and bug reports? Getting back to testing out Silver after a few weeks hiatus.