Skip to content

Instantly share code, notes, and snippets.

/spoko.rb Secret

Created June 2, 2015 08:02
Show Gist options
  • Save anonymous/8fcdf6b388f5081b0da5 to your computer and use it in GitHub Desktop.
Save anonymous/8fcdf6b388f5081b0da5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
class Spoko < Array
attr_reader :nowy
def initialize
@nowy = 1
super
end
end
aa = Spoko.new
aa << "Miód" << "Lód" << "Rak" << "Parasol"
bb = Spoko.new
bb.push("a").push("b")
puts "element bb nowy=#{bb.nowy}"
aa += bb
#p aa.map { |i| i.reverse }
aa.delete_at(2)
puts "element 1 = #{aa[1]} wielkość=#{aa.size} nowy=#{aa.nowy}"
aa.each do |a|
puts " #{a} [#{a.class.name}] "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment