Skip links

Sorbet vs RBS in Ruby

Jump To Section

Usually when we define programming languages, quite often we can read about the fact that they are divided into statically typed or dynamically typed languages.
breaking the illusion that physical stores

Introduction

int variable_name_that_is_a_number 
variable = 2 

variable = “2

How does it work?

sig {params(x: SomeType, y: SomeOtherType).returns(MyReturnType)} 
def foo(x, y); ...; end 
class User 
  attr_reader login: String 
  attr_reader email: String 

  def initialize: (login: String, email: String) -> void 
end 

class Bot 
  attr_reader name: String 
  attr_reader email: String 
  attr_reader owner: User 

  def initialize: (name: String, owner: User) -> void 
end 

Metaprogramming & overloading

sig {params(x: String).returns(MyReturnType)} 
sig {params(x: Integer, y: Integer).returns(MyReturnType)}
def foo(x, y = 0); ...; end 
def foo: (x: String | Integer, y: Integer) -> MyReturnType | MyOtherReturnType 
-> singleton(MyReturnType) 

Summary/What does the future hold?

Picture of admin

admin

Subscribe

Suggested Reading

Ready to Unlock Your Enterprise's Full Potential?