Skip to content

Conversation

@gianlucatomasino
Copy link

No description provided.

@arialdomartini
Copy link
Contributor

Smart solution!
I didn't know that enum had that capability! It is really impressive!

It's apparent that the hardest part is the default execution path of the switch statement. @gianlucatomasino used a try/catch (which is somehow a hidden if)
I used a DefaultedMap and, guess what? Yes! It contains an if

  public Object More ...get(Object key) {
        // create value for key if key is not currently in the map
        if (map.containsKey(key) == false) {
            if (value instanceof Transformer) {
                return ((Transformer) value).transform(key);
            }
            return value;
        }
        return map.get(key);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants