Writing Better, Type-safe Code with Sorbet

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 #code #type-safe https://www.rubyonrails.ba/single/writing-better-type-safe-code-with-sorbet

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles