Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created January 3, 2012 19:44
Show Gist options
  • Save garybernhardt/1556539 to your computer and use it in GitHub Desktop.
Save garybernhardt/1556539 to your computer and use it in GitHub Desktop.
Python array methods:
>>> [m for m in dir([]) if not m.startswith("_")]
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse',
'sort']
Ruby array methods:
>> ([].methods - Object.methods).sort
=> ["&", "*", "+", "-", "<<", "[]", "[]=", "all?", "any?", "assoc", "at",
"choice", "clear", "collect", "collect!", "combination", "compact", "compact!",
"concat", "count", "cycle", "delete", "delete_at", "delete_if", "detect",
"drop", "drop_while", "each", "each_cons", "each_index", "each_slice",
"each_with_index", "empty?", "entries", "enum_cons", "enum_slice",
"enum_with_index", "fetch", "fill", "find", "find_all", "find_index", "first",
"flatten", "flatten!", "grep", "group_by", "index", "indexes", "indices",
"inject", "insert", "join", "last", "length", "map", "map!", "max", "max_by",
"member?", "min", "min_by", "minmax", "minmax_by", "nitems", "none?", "one?",
"pack", "partition", "permutation", "pop", "product", "push", "rassoc",
"reduce", "reject", "reject!", "replace", "reverse", "reverse!",
"reverse_each", "rindex", "select", "shift", "shuffle", "shuffle!", "size",
"slice", "slice!", "sort", "sort!", "sort_by", "take", "take_while", "to_ary",
"transpose", "uniq", "uniq!", "unshift", "values_at", "yaml_initialize", "zip",
"|"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment