P
Pokkai Dokkai
# in source1.rb
class C1
def met
@bb
puts @bb
end
end
# in source2.rb
require 'source1.rb'
class C2
def met
@aa=10
C1.new.met
end
end
#-------------
see above source code
how to pass @aa(in C2) value to @bb(in C1) ?
@aa is a dynamic value
not allowed conditions are
1. class variable ,global variable are NOT allowed
2. passing arguments is not allowed( C1.new.met(@aa) is not allow)
3. there is no inheritance relationship between class C1,C2
4. should not modify class C2 and source2.rb
allowed conditions are
1. instance variable ,local variable are allowed
2. iterators ,callback are allowed
3. allowed to modify class C1 and source1.rb (if needed)
4. others are allowed
i got this aptitude ruby question from my friend(he got it from an
interview)
can any one solve this?
class C1
def met
@bb
puts @bb
end
end
# in source2.rb
require 'source1.rb'
class C2
def met
@aa=10
C1.new.met
end
end
#-------------
see above source code
how to pass @aa(in C2) value to @bb(in C1) ?
@aa is a dynamic value
not allowed conditions are
1. class variable ,global variable are NOT allowed
2. passing arguments is not allowed( C1.new.met(@aa) is not allow)
3. there is no inheritance relationship between class C1,C2
4. should not modify class C2 and source2.rb
allowed conditions are
1. instance variable ,local variable are allowed
2. iterators ,callback are allowed
3. allowed to modify class C1 and source1.rb (if needed)
4. others are allowed
i got this aptitude ruby question from my friend(he got it from an
interview)
can any one solve this?