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.
privatecell_at(x: u32,y: u32): Cell{returnthis.cells.get(`${x}-${y}`)}However, AssemblyScript always throws an error instead of returning null.
| get(key: K): V{ |
| letentry=this.find(key,HASH<K>(key)); |
| if(!entry)thrownewError(E_KEYNOTFOUND);// cannot represent `undefined` |
| returnentry.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?
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.
However, AssemblyScript always throws an error instead of returning null.
assemblyscript/std/assembly/map.ts
Lines 103 to 107 in 8257b1c
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?