Dictionary.Lookup - Default value type mismatch?

Using Xojo.Core.Dictionary
When the key does not exist, this line yeilds a runtime exception TypeMismatchException: “Expected array of String but got Text” :

Dim myValues() As String = MyDictionary.Lookup(myKey,Array("[MISSING CHOICES]"))

The dictionary is initialized and has contents of string arrays.

Am I missing some concept here?

This code works:

Dim asdf() as string = array("asdf")

Yeah, the problem is that the lookup method has to make an assumption about the type of objects in that array and because it’s a new dictionary, it also assumes it is an array of Text. If you define that array in a variable it works just fine because it doesn’t have to guess:

Dim DefaultValues() as String = Array("[MISSING CHOICES]") Dim myValues() As String = MyDictionary.Lookup(myKey, DefaultValues)

Side, but related question:
If I were using a classic framework dictionary would it fall back on a String type instead of Text type?

I suspect it would use String, but I haven’t tested that.

You can also keep it from guessing by using CType to tell the compiler what you want. This will work too:

dim arr() as string = d.Lookup( key, array( CType( "a", string ), "b", "c" ) )