How can I write an extension function on Collection

I’m trying to write an average() function as an extension of any Collection<Number> . I feel like this should be possible with something like reification and reflection? But I can’t figure it out. It seems the problem is that Number doesn’t have a plus() method?

Can this be done?

submitted by /u/sacheie
[link] [comments]