I am having a class G and my custom function func which i expect to take a block like this:
class G
def func(&block)
return '1' unless block_given?
# More code
end
end
I think that now when i do
G g = new G
g.func {|t| t}
block_given? should return true but its returning false
I hve tried following variants as well to no resort
g.func do |t|
end
Any help would be appreciated.
It’s working fine if you correct some minor syntax errors. Note that there is no type declaration for ruby variables and object instantiation is done through an instance method of class
Classinstead with keyword (like in Java):