[Biococoa-dev] mass calculator bug
John Timmer
jtimmer at bellatlantic.net
Sat Aug 28 13:25:45 EDT 2004
>
> On Aug 28, 2004, at 11:13 AM, John Timmer wrote:
>
>> And please fix my experimentation with the adenosine @"A" -> 'A'
>> conversion.
>
> Now I look closer at that code:
>
> NSDictionary *tempDict = [baseDefinitions objectForKey: @"A"];
> if ( tempDict != nil && [tempDict isKindOfClass: [NSDictionary
> class]] ) {
> adenosineRepresentation = [[BCNucleotideDNA alloc]
> initWithSymbol: [@"A" characterAtIndex: 0]];
> [baseDefinitions removeObjectForKey: @"A"];
> }
>
> Why not write this as one line:
>
> adenosineRepresentation = [[BCNucleotideDNA alloc] initWithSymbol:'A'];
>
> I don't understand the function of tempDict, and the removeObjectForKey
> line.
The use of tempDict is just basic error trapping. If the file's corrupted,
they key could be absent or malformed, so I check whether it's present and a
valid NSDictionary before trying to use it.
If we were being really careful, I'd have an "else" statement that threw an
exception, but I can't really decide how best to define exceptions at this
point.
JT
_______________________________________________
This mind intentionally left blank
More information about the Biococoa-dev
mailing list