-
-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Overview
A feature proposal to add Tuple type support to T-Ruby.
A tuple is an array-like type with a fixed length where each position can have a different type. Implementing this with TypeScript-like syntax would significantly enhance T-Ruby's type expressiveness.
Proposed Syntax
# Basic tuple type
def get_user_info: [String, Integer]
["Alice", 25]
end
# Rest elements
def get_values: [String, *Integer]
["header", 1, 2, 3]
end
# Optional elements
def parse_result: [Boolean, String?]
[true, nil]
endUse Cases
- Multiple return values: Explicitly specify types for each value when returning multiple values from a function
- Structured data: Represent fixed structures like CSV rows, coordinates, key-value pairs
- Pattern matching: Combine with Ruby 3.0+ pattern matching for type-safe destructuring
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Done