Timeline for Safe navigation with Object to Decimal in Map<String,Object>
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 27, 2021 at 19:03 | vote | accept | Alexander Aeons Torn | ||
Oct 27, 2021 at 18:10 | answer | added | Óscar Gómez Balaguer | timeline score: 2 | |
Oct 27, 2021 at 17:28 | comment | added | Jeferson Chaves |
Fair enough, what about storing (Decimal) testMap.get('field1') first in a variable and then using the safe-navigator? I'm assuming this might be a corner case of safe-navigator not yet covered.
|
|
Oct 27, 2021 at 17:21 | comment | added | Alexander Aeons Torn | I tried it, same error. | |
Oct 27, 2021 at 16:29 | comment | added | Jeferson Chaves |
Can you try to surround your cast before the safe-navigator? Decimal new_decimal = ((Decimal)testMap.get('field1'))?.set_scale(2);
|
|
Oct 27, 2021 at 16:23 | history | asked | Alexander Aeons Torn | CC BY-SA 4.0 |