Interesting Type Mismatch Error

I am setting a Picture variable to a picture and I get the following error:

Type mismatch error.  Expect class Picture, but got class Picture.
tmpHandPic(a) = GetCard(50, "0").Pic

Both point to a picture so I am not sure where the error lies.


Dim pic As Picture = GetCard(50, "0").Pic tmpHandPic(a) = pic
Then you will know which of the two is not a Picture.

I found the issue. I forgot that the .Pic was ALSO an array. This is what happens when one doesn’t look at a project for months.

I’m going to change my code a bit anyway to make it cleaner and less repetitive.

Maybe you could consider to use the plural for arrays (and dictionaries)?

I don’t understand.

When a variable is normal, use a singular name : myVar

When a variable is an array, use plural : myVars

Pic : Picture
Pics : Array of pictures

Prefixes also help in such a situation.
ar for array, so arpTempHandle lets us know it’s an array of picture objects for whatever purpose TempHandle might be.

plus the error message needs to be corrected, it should be

I’ve noticed that many of Xojo’s Syntax Error messages aren’t very helpful at telling me what I did wrong.

I got another unhelpful message today. It told me that I used the same variable name with different types and it didn’t know which one I was referring to. It should have said that the Method required more parameters than was passed.

This is almost a bad as when I get an error code on my gaming console and I’m forced to go online to HOPEFULLY figure out what went wrong.

Anyway thank you all for the help.