write a class, this class in ruby like this:
when you create a object of this class, it will take a pair of chars as surrounding chars and any number of strings. it will put the surrounding chars to each string. and safe the result in a string as the state of the object.
for example, assuming the name of this class is Enclose,
then you can create an object of this class and provide surrounding chars like this:
obj = Enclose.new(“<“, “>”, “i”, “love”, “you”)
then the object will hold an instance variable (array) with this value:
[““, “
you can also reset the instance variable by calling
obj.set(“<“, “>”, “i”, “love”, “you”, “very”, “much”)
then the object will hold an instance variable with this value:
[““, “
then add an singleton method to this object, the method will reverse the order of the instance variable


0 comments