News for hackers. Stuff that matters.
Re:Go Replaces Interface{} with 'Any' by peoplefromibiza on Tuesday December 14, 2021 @06:42PM (#29559752)
this is nice, especially for the function clauses

Elixir is my daily drive and working in Java made me miserable until I started working around the lack of pattern matching facilities

Error handling is the worst part, I think a simple

  switch (retval) {
    Ok(val):
       ...
       break;
    Error(err):
       ...
would make Java much more pleasant, even without full pattern matching everywhere.
Re:Go Replaces Interface{} with 'Any' by crdrost on Tuesday December 14, 2021 @10:25PM (#29561711)
This sorta exists in Java 17:

    sealed interface Result<T> 
        permits Ok, Error {}
    record Ok<T>(value: T) implements Result<T> {}
    record Error<T>(error: Throwable) implements Result<T> {}
    
    // to consume
    switch (result) {
      case Error e -> e.error().getMessage(),
      case Ok v -> v.value().toString()
    }