method
clear
v1_8_7_330 -
Show latest stable
- Class:
Array
clear()public
Removes all elements from self.
a = [ "a", "b", "c", "d", "e" ] a.clear #=> [ ]
/*
* call-seq:
* array.clear -> array
*
* Removes all elements from _self_.
*
* a = [ "a", "b", "c", "d", "e" ]
* a.clear #=> [ ]
*/
VALUE
rb_ary_clear(ary)
VALUE ary;
{
rb_ary_modify(ary);
RARRAY(ary)->len = 0;
if (ARY_DEFAULT_SIZE * 2 < RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, ARY_DEFAULT_SIZE * 2);
RARRAY(ary)->aux.capa = ARY_DEFAULT_SIZE * 2;
}
return ary;
} Related methods
- Instance methods
- &
- *
- +
- -
- <<
- <=>
- ==
- []
- []=
- abbrev
- assoc
- at
- choice
- clear
- collect
- collect!
- combination
- compact
- compact!
- concat
- count
- cycle
- dclone
- delete
- delete_at
- delete_if
- drop
- drop_while
- each
- each_index
- empty?
- eql?
- fetch
- fill
- find_index
- first
- flatten
- flatten!
- frozen?
- hash
- include?
- index
- indexes
- indices
- initialize_copy
- insert
- inspect
- join
- last
- length
- map
- map!
- nitems
- pack
- permutation
- pop
- pretty_print
- pretty_print_cycle
- product
- push
- rassoc
- reject
- reject!
- replace
- reverse
- reverse!
- reverse_each
- rindex
- select
- shelljoin
- shift
- shuffle
- shuffle!
- size
- slice
- slice!
- sort
- sort!
- take
- take_while
- to_a
- to_ary
- to_s
- to_yaml
- transpose
- uniq
- uniq!
- unshift
- values_at
- yaml_initialize
- zip
- |
- Class methods
- []
- new