getValue method

(I wrote this directly in the github online editor, so no guarantee of compilation