How would you do rose memoization with Sorbet?
问题 Trying to annotate this code, the rose memoization ( @||= ) gives me an error Use of undeclared variable @git_sha . # typed: strict # frozen_string_literal: true module Util extend T::Sig sig { returns(String) } def self.git_sha @git_sha ||= ENV.fetch( 'GIT_REV', `git rev-parse --verify HEAD 2>&1` ).chomp end end As far as I've found, I should declare the variable's type with T.let but haven't figured out specifically how. 回答1: Sorbet now has built-in support for this, as of 0.4.4679. Before