Skip to content

Instantly share code, notes, and snippets.

@thephw
Created April 29, 2015 21:16
Show Gist options
  • Save thephw/f9de3a5ba48d7e777d03 to your computer and use it in GitHub Desktop.
Save thephw/f9de3a5ba48d7e777d03 to your computer and use it in GitHub Desktop.
Get length of linked list
class IntList
attr_accessor :value, :next
end
def get_length(l)
return 0 if l.nil?
len = 1 + get_length(l.next)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment