Groovy - prototype extension through ExpandoMetaClass

Number.metaClass {
sqrt = { Math.sqrt(delegate) }
}

assert 9.sqrt() == 3
assert 4.sqrt() == 2

Comments

Popular posts from this blog

தீபம் பிளக்ஸ்

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

காது புடி வாத்தியார்