Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class One
- attr_reader :array
- def initialize(array)
- @array = array
- end
- end
- class Two < One
- attr_reader :array
- def initialize
- @array = []
- end
- end
- array = ["D","E"]
- a = One.new(array)
- b = Two.new
- c = Two.new
- def place_string(element,location)
- if location == "b"
- take element, copy it and place it into @array in b
- elsif location == "c"
- take element, copy it and place it into @array in c
- end
- end
- a.place_string("D","b")
- Output:
- a.array = ["D","E"]
- b.array = ["D"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement