- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 676
Open
Labels
Description
Question
I'm writing an AssemblyScript version of Conways Game of Life - https://github.com/KieranP/Game-Of-Life-Implementations
Part of it needs to fetch values from a Map but the key may not be there.
private cell_at(x: u32, y: u32): Cell {
  return this.cells.get(`${x}-${y}`)
}However, AssemblyScript always throws an error instead of returning null.
assemblyscript/std/assembly/map.ts
Lines 103 to 107 in 8257b1c
| get(key: K): V { | |
| let entry = this.find(key, HASH<K>(key)); | |
| if (!entry) throw new Error(E_KEYNOTFOUND); // cannot represent `undefined` | |
| return entry.value; | |
| } | 
Map.find() is a private method, so I can't use that. And trying to use try/catch throws error ERROR AS100: Not implemented: Exceptions.
So how am I supposed to do this, try and fetch a map value, and handle when the map doesn't have the expected value?