How can I find the complexity of a Ruby method?
For example length? If I look at the source code, I see this:
static VALUE rb_ary_len
It is just O(1) for the length method. The length of an array is stored in a variable and can be returned without further calculations.
O(1)
length
How to find out? By reading the source code and analysing the implementation and algorithms.