Writing Better, Type-safe Code with Sorbet
02-Jul-2020 1313
Without a unit test covering the case when action returns nil, such code could go by undetected. To make matters worse, what if foo() is overridden by a child class to have a different return type? When types are inferred from the names of variables such as in the example, it is hard for any new developer to know that their code needs to handle different return types. There is no clue to suggest what result contains, so the developer would have to search the entire code base for what it could be.Let’s see the same example with method signatures.
Writing Better, Type-safe Code with Sorbet #ruby #rubydeveloper #rubyonrails #Writing #Better, #Type-safe #Sorbet #code #type-safe https://www.rubyonrails.ba/link/writing-better-type-safe-code-with-sorbet