Computer says 'no'.
You cant extend a generic instantiation ( even in C#) which is the form you're attempting here
- the error message is referring to the 'of decimal' (decimal recognised as a Type) rather than expected/allowed in generic dcl 'of T' ( T as an identifier)
If you try to make an extension of a generic template which would be the the expected route you hit issues with determining T.minValue/maxValue and inability to do comparisons on generic Types.
C# handles this with placing constraints on the template Type (on classes anyway havent tried on extensions)
but cobra disallows constraints on extensions
i.e
#Unworkable/wrong in many ways
extend List<of T>
# where T must be Number # compile error fm cobra no constraints on extensions
def max as T
m = this[0] # cant use T.minValue as cant determine method existance
for i in this
if i > m # compile error generics
m = i
return m
def min as T
m = this[0]
for i in this
if i < m # compile error generics
m = i
return m
class X
def main is shared
l = List<of decimal>()
l.add(123.1)
l.add(44.2)
l.add(87.91)
print l.min
print l.max
You have to do the extension manually
class DecExtn
"""Decimal Extn utility class on a generic instantiation."""
def max(l as List<of decimal>) as decimal is shared
m = decimal.minValue
for i in l
if i > m
m = i
return m
def min(l as List<of decimal>) as decimal is shared
m = decimal.maxValue
for i in l
if i < m
m = i
return m
class X
def main is shared
l = List<of decimal>()
l.add(123.1)
l.add(44.2)
l.add(87.91)
print DecExtn.min(l)
print DecExtn.max(l)