Skip to content

Instantly share code, notes, and snippets.

@okabe-yuya
Created September 25, 2022 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okabe-yuya/d2c83981b4d0a18e2c5ffede93c5a106 to your computer and use it in GitHub Desktop.
Save okabe-yuya/d2c83981b4d0a18e2c5ffede93c5a106 to your computer and use it in GitHub Desktop.
class StringArray
attr_reader :s_array
def initialize
@s_array = ''
end
def push(v)
@s_array += "#{v}SPLIT"
self
end
def each(&block)
block.call
end
end
data = [ [], StringArray.new ].each { |d| 5.times { |n| d.push(n+1) } }
p data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment