>>> On Mar 25, 2007, at 10:32 AM, John Kubie wrote:
>>>
>>>>
>>>> On Mar 25, 2007, at 9:49 AM, Charles Yeomans wrote:
>>>>
>>>>> What is it that you find confusing about the Dictionary interface?
>>>>
>>>> The first awkwardness is the apparent necessity to test for the
>>>> existence of a key before getting the key-value combination
>>>> Next, the word "key" is not used when getting a value associated
>>>> with
>>>> a key.
>>
>> ElfDataDictionary doesn't impose this. You can just get value and if
>> it doesn't exist, nil is returned.
>
>
> But a REALbasic Dictionary allows one to store anything as a value,
> including nil. That leaves no magic value to return when no entry
> with the specified key exists. Raising a KeyNotFoundException is
> then the best response.
It's not the best response. I don't see how it is. In RB you do this:
if dict.HasKey("bla") then
value = dict.value("bla")
else
value = NewBla
dict.value("bla") = Value
end if
With ElfData it's this:
value = dict.value("bla")
if value = nil then
value = NewBla
dict.value("bla") = Value
end if
So it's the same, only faster and using less code.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>