Ruby 3 - Type Signatures
Started by Ryan




0 posts in this topic
Ryan
Administrator
*****


Administrators

28 posts 16 threads Joined: Aug 2020
30-07-2020, 10:10 PM -
#1
Major changes seem to be coming in Ruby 3 with a new type signature language. RBS is a new language that will be supported by Ruby to allow for native static type checking.

An example of RBS:

Code:
# sig/merchant.rbs

class Merchant
  attr_reader token: String
  attr_reader name: String
  attr_reader employees: Array[Employee]

  def initialize: (token: String, name: String) -> void

  def each_employee: () { (Employee) -> void } -> void
                   | () -> Enumerator[Employee, void]
end

https://developer.squareup.com/blog/the-...-3-typing/


Forum Jump:


Users browsing this thread: 1 Guest(s)