[Feature] `#unwrap_optional` helper

Open Beginner friendly
#2,970 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
ruby
Domain
devtools

Research direction

Start by locating RBS::Types::_TypeBase and RBS::Types::Optional, then read nearby type helpers and their tests if present. Add unwrap_optional so non-optional types return themselves while Optional returns its underlying type. Done means both behaviors are covered and the relevant test suite passes.

Written by the indexing model from the issue text.

Description

It's a really common operation to unwrap the optionality out of a type, e.g. turning String? into String.

I'd propose (in psuedocode):

interface RBS::Types::_TypeBase
  # @overridable
  #: -> _TypeBase
  def unwrap_optional
    self # not optional, nothing to unwrap.
  end
end

class RBS::Types::Optional
  # @override
  #: -> _TypeBase
  def unwrap_optional
    type
  end
end
Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rbs

All issues in ruby/rbs

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.