2 ms·
So once again, if you didn't have Optional, what should Map#get return?
by lmm 11y ago
So once again, if you didn't have Optional, what should Map#get return?
- specialist 11y agoReally? class Widget {...} class final NullWidget extends Widget { static NULL_WIDGET = new NullWidget(); ... } class WidgetMap extends HashMap<String,Widget> { Widget get( String key ) { if( contains( key )) { return super.get( key ); } return NULL_WIDGET; } ... }