Skip to content

Error handling #13

Open
Open
@MatheusRich

Description

@MatheusRich

V's error handling seems to be a good fit here.

This would play nicely with the idea of "soft-typing" (i.e. world's laziest type checker):

User = {
  db = [{id: 1, name "Matz"}, {id: 2, name "Matheus"}]

  # The ! here means it may fail
  find! = fn { |id|
    List.each(db, fn { |user|
      if user.id == id { return user; }
    });

    return none; # or return error("msg")
  }
}

User.find!(3) or { {id: 0, name "Dummy user"} }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions