feat: update list handling to Ruby v2 array syntax#406
Merged
Conversation
- Replace list() wrapper with direct array syntax (@items.push(...)) - Change from 1-indexed to 0-indexed - Add array literal initialization (@Items = [...]) - Add empty? method - Add Lists section to v1-diff documents (EN/JA) Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Lists (Arrays) section with 0-indexed array operations - Fix Sensing to v2 syntax (keyboard.pressed?, mouse.x, timer.value) - Add list() to Forbidden Methods - Update Critical Syntax Warnings for v2 sensing and list() Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/smalruby3-list-v2-array-syntax/ |
- Change List class to 0-indexed (Ruby standard) - index() returns nil when not found (was 0) - [] returns nil for out-of-range (was "") - Remove list() wrapper method from Target - Update monitor_renderer to access list variable directly - Delegate delete_at/insert directly to Array (no special values) Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- delete_at("last") → list.delete_at(-1) # @ruby:array:delete_at:last
- delete_at("random") → list.delete_at(rand(0...list.length)) # @ruby:array:delete_at:random
- insert("last", item) → list.push(item) # @ruby:array:insert:last
- insert("random", item) → list.insert(rand(0..list.length), item) # @ruby:array:insert:random
Refs #405
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generator: check @ruby:array:delete_at:last/random and @ruby:array:insert:last/random comments for round-trip output. Converter: detect delete_at(-1) as "last" special value and attach @ruby:array:delete_at:last comment for round-trip. Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- empty? method round-trip - show_list/hide_list round-trip Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ruby:array:delete_at:last/random and @ruby:array:insert:last/random comments are round-trip metadata stored as block comments, not meant to be visible in the Ruby editor. Remove inline comment output from the Generator so these comments stay hidden like other @ruby: markers. Refs #405 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Mar 28, 2026
…uby3-list-v2-array-syntax feat: update list handling to Ruby v2 array syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ruby v2 で
list()を廃止し配列リテラル[]+ 0 起点インデックスを使う実態を、言語仕様・Rubytee プロンプト・smalruby3 gem に反映する。Closes #405
Implementation Steps
Definition of Done
@ruby:array:delete_at:lastコメントの round-trip 成功Test plan
@ruby:array:delete_at:last検出テスト (round-trip)🤖 Generated with Claude Code