Skip to main content

T-Ruby v0.0.41 Released

T-Ruby v0.0.41 introduces keyword arguments syntax, bringing more expressive type annotations to your Ruby code. (PR#27)

Keyword Arguments Syntax

📖 See also: Optional & Rest Parameters

This release adds new syntax for keyword arguments that distinguishes them from positional arguments:

Keyword Arguments with Destructuring

def create_user({ name: String, email: String }): User
User.new(name: name, email: email)
end

# Call with keyword arguments
create_user(name: "Alice", email: "alice@example.com")

Hash Literal Parameters

def configure(config: { host: String, port: Integer }): void
# config is a Hash parameter, not destructured keywords
end

Double Splat for Forwarding

def forward_options(**opts: Symbol): void
other_method(**opts)
end

Syntax Summary

SyntaxMeaning
{ name: String }Keyword arguments (destructured)
config: { host: String }Hash literal parameter
**opts: TypeDouble splat for forwarding

Bug Fixes

Fixed Return Type Erasure for Parentheses-less Methods (PR#24, Issue#23)

Previously, methods defined without parentheses would retain their type annotations after compilation, resulting in invalid Ruby code:

# Before (T-Ruby source)
def greet: String
"Hello!"
end

# ❌ Bug: Type annotation was not removed
def greet: String
"Hello!"
end

# ✅ Fixed: Now correctly compiles to valid Ruby
def greet
"Hello!"
end

This fix ensures that all method signatures—with or without parentheses—are properly transformed into valid Ruby code.

Internal Improvements

  • Extracted common string utilities to StringUtils module

Upgrade

gem update t-ruby