Created
November 27, 2011 10:27
-
-
Save devnoo/1397363 to your computer and use it in GitHub Desktop.
Seven languages in seven weeks : Solutions IO Day2 average on list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List myAverage := method( | |
total := 0 | |
self foreach(i, element, ( | |
if (element type == "Number", total = total + element, Exception raise("element is not a number")) | |
)) | |
total / self size | |
) | |
array := list(3,4,5) | |
array myAverage println | |
array := list(list(3),4,5) | |
array myAverage println |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment