ライブラリ
- English (44)
- ビルトイン (3438)
- abbrev (11)
- benchmark (22)
- bigdecimal (11)
-
cgi
/ core (44) - coverage (6)
- csv (363)
- dbm (22)
- delegate (11)
- erb (11)
- expect (22)
- fileutils (132)
- getoptlong (22)
-
irb
/ inspector (11) - json (55)
- logger (11)
- matrix (121)
-
minitest
/ unit (7) - mkmf (44)
-
net
/ imap (55) - objspace (11)
- observer (22)
- open3 (99)
- openssl (66)
- optparse (176)
- ostruct (9)
- pathname (11)
- pp (22)
- pstore (11)
- psych (23)
- rake (308)
-
rake
/ rdoctask (22) -
rake
/ testtask (22) -
rdoc
/ context (11) -
rdoc
/ text (11) - readline (22)
-
rexml
/ document (33) -
rexml
/ parsers / pullparser (22) -
rexml
/ parsers / ultralightparser (11) -
rinda
/ rinda (33) -
rinda
/ tuplespace (44) - rubygems (33)
-
rubygems
/ command (66) -
rubygems
/ command _ manager (22) -
rubygems
/ commands / build _ command (11) -
rubygems
/ commands / dependency _ command (11) -
rubygems
/ commands / update _ command (11) -
rubygems
/ commands / which _ command (22) -
rubygems
/ config _ file (11) -
rubygems
/ dependency (11) -
rubygems
/ dependency _ installer (66) -
rubygems
/ dependency _ list (22) -
rubygems
/ doc _ manager (11) -
rubygems
/ ext / configure _ builder (11) -
rubygems
/ ext / ext _ conf _ builder (11) -
rubygems
/ ext / rake _ builder (11) -
rubygems
/ format (11) -
rubygems
/ gem _ path _ searcher (22) -
rubygems
/ indexer (22) -
rubygems
/ old _ format (11) -
rubygems
/ package / tar _ header (11) -
rubygems
/ platform (11) -
rubygems
/ requirement (22) -
rubygems
/ security (22) -
rubygems
/ source _ index (22) -
rubygems
/ source _ info _ cache (22) -
rubygems
/ spec _ fetcher (44) -
rubygems
/ specification (154) -
rubygems
/ user _ interaction (22) -
rubygems
/ version (22) - scanf (36)
- set (22)
- shell (24)
-
shell
/ command-processor (6) -
shell
/ filter (6) -
shell
/ process-controller (18) - shellwords (33)
- socket (187)
- thwait (6)
- tsort (44)
-
webrick
/ config (11) -
webrick
/ httprequest (22) -
webrick
/ https (11) -
webrick
/ httpserver (11) -
webrick
/ httputils (33) - win32ole (77)
- zlib (22)
クラス
-
ARGF
. class (77) - Array (2049)
- BasicSocket (11)
-
Benchmark
:: Tms (11) - BigDecimal (11)
-
CGI
:: Cookie (11) - CSV (165)
-
CSV
:: Row (66) -
CSV
:: Table (121) - Complex (11)
- Coverage (6)
- DBM (22)
- Data (4)
- ERB (11)
-
Encoding
:: Converter (33) - Enumerator (22)
-
Gem
:: Command (66) -
Gem
:: CommandManager (22) -
Gem
:: Commands :: BuildCommand (11) -
Gem
:: Commands :: DependencyCommand (11) -
Gem
:: Commands :: UpdateCommand (11) -
Gem
:: Commands :: WhichCommand (22) -
Gem
:: ConfigFile (11) -
Gem
:: Dependency (11) -
Gem
:: DependencyInstaller (66) -
Gem
:: DependencyList (22) -
Gem
:: DocManager (11) -
Gem
:: Ext :: ConfigureBuilder (11) -
Gem
:: Ext :: ExtConfBuilder (11) -
Gem
:: Ext :: RakeBuilder (11) -
Gem
:: Format (11) -
Gem
:: GemPathSearcher (22) -
Gem
:: Indexer (22) -
Gem
:: OldFormat (11) -
Gem
:: Package :: TarHeader (11) -
Gem
:: Platform (11) -
Gem
:: Requirement (22) -
Gem
:: Security :: Policy (11) -
Gem
:: Security :: Signer (11) -
Gem
:: SourceIndex (22) -
Gem
:: SourceInfoCache (22) -
Gem
:: SpecFetcher (44) -
Gem
:: Specification (154) -
Gem
:: StreamUI (11) -
Gem
:: Version (22) - GetoptLong (22)
- Hash (44)
- IO (56)
- IPSocket (33)
-
IRB
:: Inspector (11) -
JSON
:: Parser (11) -
JSON
:: State (11) - Logger (11)
- MatchData (55)
- Matrix (55)
- Method (40)
-
MiniTest
:: Unit (2) -
MiniTest
:: Unit :: TestCase (2) - Module (60)
-
Net
:: IMAP (11) -
Net
:: IMAP :: BodyTypeBasic (11) -
Net
:: IMAP :: BodyTypeMessage (11) -
Net
:: IMAP :: BodyTypeMultipart (11) -
Net
:: IMAP :: BodyTypeText (11) - NilClass (11)
- Object (114)
-
OpenSSL
:: BN (11) -
OpenSSL
:: X509 :: ExtensionFactory (33) - OpenStruct (9)
- OptionParser (132)
-
OptionParser
:: ParseError (44) - PStore (11)
- Pathname (11)
-
RDoc
:: Context (11) -
REXML
:: Element (11) -
REXML
:: Entity (22) -
REXML
:: Parsers :: PullEvent (22) -
REXML
:: Parsers :: UltraLightParser (11) -
Rake
:: Application (22) -
Rake
:: FileList (143) -
Rake
:: NameSpace (11) -
Rake
:: RDocTask (22) -
Rake
:: Task (55) -
Rake
:: TaskArguments (11) -
Rake
:: TestTask (22) - Random (55)
- Range (34)
- Rational (22)
- Regexp (22)
-
Rinda
:: TupleEntry (11) -
Rinda
:: TupleSpace (33) -
Rinda
:: TupleSpaceProxy (33) -
RubyVM
:: AbstractSyntaxTree :: Node (6) -
RubyVM
:: InstructionSequence (11) - Set (22)
- Shell (24)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) -
Shell
:: ProcessController (18) - Socket (110)
-
Socket
:: Option (11) - String (53)
- Struct (20)
- TCPSocket (11)
- ThreadsWait (6)
- Time (11)
- UDPSocket (11)
- UnboundMethod (22)
- Vector (66)
-
WEBrick
:: HTTPRequest (33) -
WEBrick
:: HTTPServer :: MountTable (11) -
WEBrick
:: HTTPUtils :: FormData (22) - WIN32OLE (11)
-
WIN32OLE
_ VARIANT (55) -
Zlib
:: GzipReader (11)
モジュール
- Benchmark (11)
-
CGI
:: QueryExtension (22) -
CGI
:: QueryExtension :: Value (22) - Enumerable (591)
- FileUtils (143)
-
GC
:: Profiler (11) - Gem (33)
-
Gem
:: UserInteraction (11) - JSON (22)
-
JSON
:: Generator :: GeneratorMethods :: Array (11) - Kernel (144)
- MiniTest (1)
-
MiniTest
:: Assertions (2) - ObjectSpace (33)
- Observable (22)
- Open3 (99)
-
OpenSSL
:: SSL :: SocketForwarder (22) - Psych (23)
-
RDoc
:: Text (11) -
Rake
:: TaskManager (44) - Shellwords (22)
- TSort (44)
-
WEBrick
:: Config (11) -
WEBrick
:: HTTPUtils (11) -
WIN32OLE
:: VARIANT (11) - Zlib (11)
オブジェクト
- ENV (22)
-
Readline
:: HISTORY (22) - main (28)
キーワード
-
$ , (11) -
$ INPUT _ RECORD _ SEPARATOR (11) -
$ OFS (11) -
$ OUTPUT _ FIELD _ SEPARATOR (11) -
$ RS (11) - & (11)
- * (33)
- + (11)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - << (22)
- <=> (11)
- == (33)
- === (7)
- =~ (15)
-
ARGUMENT
_ FLAGS (11) - ARGV (11)
-
ARRAY
_ METHODS (11) -
DEFAULT
_ IGNORE _ PATTERNS (11) -
DEFAULT
_ RAKEFILES (11) -
DELEGATING
_ METHODS (11) - DIRECTORIES (11)
- DelegateClass (11)
- DigestAuth (11)
- Enumerable (11)
- FIELDS (11)
- METHODS (11)
-
MUST
_ DEFINE (11) -
MUST
_ NOT _ DEFINE (11) - Marshal フォーマット (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - ORDERINGS (11)
- Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (11)
- Ruby用語集 (11)
-
SEV
_ LABEL (11) -
SPECIAL
_ RETURN (11) - TYPES (11)
-
VT
_ ARRAY (11) -
WIN
_ PATTERNS (11) - [] (198)
- []= (55)
-
_ invoke (11) - abbrev (11)
- accept (11)
-
accept
_ nonblock (11) - actions (11)
-
active
_ jobs (6) -
add
_ attributes (11) -
add
_ bindir (11) -
add
_ extra _ args (11) -
add
_ observer (11) -
add
_ to (11) - addr (33)
- all? (36)
- any? (56)
- append (7)
-
arg
_ names (11) - args (22)
- argv (11)
- array (11)
-
array
_ attribute (11) -
array
_ attributes (11) -
array
_ nl (11) -
assert
_ send (1) - assoc (33)
- at (11)
-
attribute
_ defaults (11) -
attribute
_ names (11) - bmbm (11)
- bsearch (44)
-
bsearch
_ index (18) - build (33)
-
build
_ args (11) - call (22)
-
capture
_ io (1) -
cert
_ chain (22) - children (6)
- chmod (11)
-
chmod
_ R (11) -
choose
_ from _ list (22) - chown (11)
-
chown
_ R (11) - cipher (11)
- clear (11)
- clone (11)
- coerce (44)
- collect (44)
- collect! (22)
- collect2 (22)
-
collect
_ concat (22) -
collect
_ method (11) -
column
_ vector (11) - combination (22)
-
command
_ names (11) - commands (11)
- compact (14)
- compact! (11)
-
compact
_ specs (11) - concat (30)
-
configured
_ args (11) - converters (11)
- convpath (11)
- count (66)
-
crc
_ table (11) -
create
_ ext _ from _ array (11) -
create
_ extension (22) -
current
_ scope (11) - cycle (22)
- deconstruct (2)
-
deconstruct
_ keys (2) -
default
_ system _ path (6) -
define
_ finalizer (22) - delete (22)
-
delete
_ at (11) -
delete
_ if (22) -
delete
_ observers (11) -
depend
_ rules (11) - dependencies (11)
-
dependent
_ gems (11) -
development
_ dependencies (11) - diagonal (11)
- difference (6)
- dig (27)
- drop (22)
-
drop
_ while (44) - dump (11)
- dup (11)
- each (22)
- each2 (22)
-
each
_ index (22) - empty? (11)
- entries (6)
-
enum
_ for (22) - eql? (22)
- expect (22)
- extension (44)
-
extra
_ args (11) - fcntl (11)
- fetch (44)
- fields (11)
-
file
_ entries (22) - fill (66)
- filter (12)
- filter! (12)
-
filter
_ backtrace (12) - find (11)
-
find
_ all (11) -
find
_ command _ possibilities (11) -
find
_ gems _ with _ sources (11) -
find
_ index (33) -
find
_ matching (11) -
find
_ paths (11) -
find
_ reverse _ dependencies (11) -
find
_ spec _ by _ name _ and _ version (11) -
find
_ type (22) - first (44)
-
flat
_ map (22) - flatten (22)
- flatten! (11)
-
force
_ encoding (11) - freeze (11)
-
gather
_ dependencies (11) -
gem
_ file _ list (11) -
gem
_ paths (11) -
gems
_ to _ install (11) - generate (11)
-
generate
_ line (11) -
get
_ all _ gem _ names (11) - getaddrinfo (11)
- gethostbyaddr (11)
- gethostbyname (22)
- getnameinfo (11)
- gets (11)
- grep (22)
- hash (11)
-
header
_ converters (11) - headers (33)
- import (11)
-
in
_ namespace (11) - include? (11)
- index (33)
- insert (11)
- inspect (11)
- install (11)
-
install
_ rb (11) -
installed
_ gems (11) - intersect? (3)
- intersection (16)
- ioctl (11)
-
is
_ a? (11) - jobs (12)
- join (22)
-
keep
_ if (22) -
keys
_ with _ inspector (11) -
kind
_ of? (11) - last (22)
-
latest
_ specs (11) -
legacy
_ repos (11) - length (33)
- libs (11)
-
line
_ stub (6) - list (33)
-
load
_ gemspecs (11) - makedirs (11)
- map (44)
- map! (22)
- map2 (11)
-
marshal
_ dump (44) -
marshal
_ load (22) - max (76)
-
max
_ by (44) - min (76)
-
min
_ by (44) - minmax (20)
- mkdir (18)
-
mkdir
_ p (11) - mkpath (11)
-
module
_ function (8) - names (11)
- new (88)
-
next
_ values (11) - none? (36)
- on (132)
- one? (36)
-
option
_ list (11) - outdated (11)
- p (11)
- pack (19)
- pack テンプレート文字列 (11)
- pair (11)
- params (11)
- parse (55)
-
parse
_ line (11) - path (11)
-
pathmap
_ explode (11) -
peek
_ values (11) - peeraddr (33)
- permutation (22)
- pipeline (11)
-
pipeline
_ r (22) -
pipeline
_ rw (22) -
pipeline
_ start (22) -
pipeline
_ w (22) - pop (22)
- prepend (7)
- prerequisites (11)
-
pretty
_ print (11) -
pretty
_ print _ cycle (11) -
primitive
_ errinfo (11) - private (32)
-
private
_ class _ method (8) - product (22)
- profile (6)
- protected (16)
- public (24)
- push (11)
- rand (33)
- rassoc (33)
-
rdoc
/ parser / c (11) -
reachable
_ objects _ from (11) - read (44)
-
read
_ all (22) - readline (11)
- readlines (66)
- recover (11)
- recvfrom (11)
-
recvfrom
_ nonblock (11) - reject (44)
- reject! (22)
-
remove
_ by _ name (11) -
repeated
_ combination (22) -
repeated
_ permutation (22) - replace (11)
- report (1)
-
required
_ attributes (11) - requirements (11)
-
resolve
_ args (11) -
response
_ handlers (11) - result (11)
- reverse (11)
- reverse! (11)
-
reverse
_ each (22) - rindex (33)
- roots (11)
- rotate (11)
- rotate! (11)
- row (11)
-
row
_ vector (11) - rss (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
ruby
_ opts (11) -
run
_ test _ suites (1) -
runtime
_ dependencies (11) -
safe
_ load (12) - sample (44)
- scan (11)
- scanf (36)
-
search
_ convpath (11) -
search
_ with _ source (22) - select (33)
- select! (22)
- sendmsg (11)
-
set
_ backtrace (11) -
set
_ eoutvar (11) - shelljoin (22)
- shift (33)
- shuffle (22)
- shuffle! (22)
- size (33)
- slice (33)
- slice! (33)
- socketpair (11)
- sort (22)
- sort! (22)
-
sort
_ by (22) -
sort
_ by! (22) - sources (11)
-
spec
_ predecessors (11) -
specific
_ extra _ args (11) - split (11)
-
split
_ all (11) -
split
_ header _ value (11) -
strongly
_ connected _ components (22) - sum (38)
- sysaccept (11)
-
system
_ path (6) - table (22)
- take (44)
-
take
_ while (44) - tasks (33)
-
test
_ methods (1) -
test
_ suites (1) - threads (6)
-
to
_ a (204) -
to
_ ary (55) -
to
_ csv (11) -
to
_ enum (22) -
to
_ h (17) -
to
_ json (11) -
to
_ s (11) -
top
_ level _ tasks (11) - transpose (11)
-
try
_ convert (11) - tsort (33)
- union (17)
- uniq (44)
- uniq! (22)
- unpack (22)
- unpack1 (8)
-
unpack
_ sockaddr _ in (11) - unparse (11)
- unshift (11)
- value (22)
-
values
_ at (44) - vartype (11)
-
verify
_ gem (11) -
waiting
_ jobs (6) -
which
_ to _ update (11) - yaml (11)
- zip (22)
- | (11)
- クラス/メソッドの定義 (11)
- メソッド呼び出し(super・ブロック付き・yield) (11)
- リテラル (11)
- 制御構造 (11)
検索結果
先頭5件
-
Array
# -(other) -> Array (42319.0) -
自身から other の要素を取り除いた配列を生成して返します。
...自身から other の要素を取り除いた配列を生成して返します。
要素の同一性は Object#eql? により評価されます。
self 中で重複していて、other中に存在していなかった要素は、その重複が保持されます。
@param other 自身から取......場合は to_ary メソッドによ
る暗黙の型変換を試みます。
@raise TypeError 引数に配列以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
[1, 2, 1, 3, 1, 4] - [4, 2] #......=> [1, 1, 3, 1]
[1, 2, 1, 3, 1, 4] - [1, 4] # => [2, 3]
//}......=> [1, 1, 3, 1]
[1, 2, 1, 3, 1, 4] - [1, 4] # => [2, 3]
//}
@see Array#difference... -
Array
# difference(*other _ arrays) -> Array (27407.0) -
自身から other_arrays の要素を取り除いた配列を生成して返します。
...自身から other_arrays の要素を取り除いた配列を生成して返します。
要素の同一性は Object#hash と Object#eql? により評価されます。
self 中で重複していて、other_arrays中に存在していなかった要素は、その重複が保持されます。......素の順と同じです。
//emlist[例][ruby]{
[ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) # => [ 3, 3, 5 ]
[ 1, 'c', :s, 'yep' ].difference([ 1 ], [ 'a', 'c' ]) # => [:s, "yep"]
//}
集合のような振る舞いが必要なら Set も参照してください。
@see Array#-... -
Array
# intersection(*other _ arrays) -> Array (27407.0) -
自身と引数に渡された配列の共通要素を新しい配列として返します。 要素が重複する場合は、そのうちの1つのみを返します。 要素の順序は自身の順序を維持します。
...持します。
@param other_arrays 自身と共通要素を取りたい配列を指定します。
配列以外のオブジェクトを指定した場合は to_ary
メソッドによる暗黙の型変換を試みます。
@raise TypeError 引数に配列以......合に発生します。
intersectionはObject#hashとObject#eql?を使って比較を行います。
//emlist[例][ruby]{
[1, 1, 3, 5].intersection([3, 2, 1]) # => [1, 3]
["a", "b", "z"].intersection(["a", "b", "c"], ["b"]) # => ["b"]
["a"].intersection......# => ["a"]
//}
@see Set#intersection, Array#&... -
Array
# rassoc(obj) -> Array | nil (27407.0) -
自身が配列の配列であると仮定して、要素の配列でインデックス 1 の要素が obj に等しいものを検索し見つかった最初の要素を返 します。該当する要素がなければ nil を返します。
...を返
します。該当する要素がなければ nil を返します。
比較は == 演算子を使って行われます。
@param obj 検索するオブジェクトを指定します。
//emlist[例][ruby]{
a = [[15,1], [25,2], [35,3]]
p a.rassoc(2) # => [25, 2]
//}
@see Array#assoc... -
Array
# transpose -> Array (27407.0) -
自身を行列と見立てて、行列の転置(行と列の入れ換え)を行いま す。転置した配列を生成して返します。空の配列に対しては空の配列を生 成して返します。
...外
TypeError が発生します。各要素のサイズが不揃いな配列に対して
は、例外 IndexError が発生します。
//emlist[例][ruby]{
p [[1,2],
[3,4],
[5,6]].transpose
# => [[1, 3, 5], [2, 4, 6]]
p [].transpose
# => []
p [1,2,3].transpose
# => -:1:in `transpose': can......not convert Fixnum into Array (TypeError)
# from -:1
p [[1,2],
[3,4,5],
[6,7]].transpose
# => -:3:in `transpose': element size differ (3 should be 2) (IndexError)
//}... -
Array
. try _ convert(obj) -> Array | nil (27325.0) -
to_ary メソッドを用いて obj を配列に変換しようとします。
...to_ary メソッドを用いて obj を配列に変換しようとします。
何らかの理由で変換できないときには nil を返します。
このメソッドは引数が配列であるかどうかを調べるために使えます。
//emlist[例][ruby]{
Array.try_convert([1]) # =>......[1]
Array.try_convert("1") # => nil
if tmp = Array.try_convert(arg)
# the argument is an array
elsif tmp = String.try_convert(arg)
# the argument is a string
end
//}... -
Array
# drop(n) -> Array (27313.0) -
配列の先頭の n 要素を捨てて、 残りの要素を配列として返します。 このメソッドは自身を破壊的に変更しません。
...は自身を破壊的に変更しません。
@param n 捨てる要素数。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop(3) # => [4, 5, 0]
# 変数aの値は変化しない
a # => [1, 2, 3, 4, 5, 0]
//}
@see Enumerable#drop, Array#drop_while, Array#shift... -
Array
# first(n) -> Array (27308.0) -
先頭の n 要素を配列で返します。n は 0 以上でなければなりません。
...なければなりません。
@param n 取得したい要素の個数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型......指定した場合に発生します。
@raise ArgumentError n が負値の場合発生します。
//emlist[例][ruby]{
ary = [0, 1, 2]
p ary.first(0)
p ary.first(1)
p ary.first(2)
p ary.first(3)
p ary.first(4)
# => []
# [0]
# [0, 1]
# [0, 1, 2]
# [0, 1, 2]
//}
@see Array#last... -
Array
# sort -> Array (27308.0) -
配列の内容をソートします。要素同士の比較は <=> 演算子を使って行います。sort はソートされた配列を生成して返します。 sort! は self を破壊的にソートし、self を返します。
...配列の内容をソートします。要素同士の比較は <=> 演算子を使って行います。sort はソートされた配列を生成して返します。
sort! は self を破壊的にソートし、self を返します。
ブロックとともに呼び出された時には、要素......list[例][ruby]{
ary1 = [ "d", "a", "e", "c", "b" ]
p ary1.sort #=> ["a", "b", "c", "d", "e"]
ary2 = ["9", "7", "10", "11", "8"]
p ary2.sort #=> ["10", "11", "7", "8", "9"] (文字列としてソートするとこうなる)
p ary2.sort{|a, b|......a.to_i <=> b.to_i } #=> ["7", "8", "9", "10", "11"] (ブロックを使って数字としてソート)
# sort_by を使っても良い
p ary2.sort_by{|x| x.to_i } #=> ["7", "8", "9", "10", "11"]
//}
@see Enumerable#sort_by
, Array#sort_by!... -
Array
# sort {|a , b| . . . } -> Array (27308.0) -
配列の内容をソートします。要素同士の比較は <=> 演算子を使って行います。sort はソートされた配列を生成して返します。 sort! は self を破壊的にソートし、self を返します。
...配列の内容をソートします。要素同士の比較は <=> 演算子を使って行います。sort はソートされた配列を生成して返します。
sort! は self を破壊的にソートし、self を返します。
ブロックとともに呼び出された時には、要素......list[例][ruby]{
ary1 = [ "d", "a", "e", "c", "b" ]
p ary1.sort #=> ["a", "b", "c", "d", "e"]
ary2 = ["9", "7", "10", "11", "8"]
p ary2.sort #=> ["10", "11", "7", "8", "9"] (文字列としてソートするとこうなる)
p ary2.sort{|a, b|......a.to_i <=> b.to_i } #=> ["7", "8", "9", "10", "11"] (ブロックを使って数字としてソート)
# sort_by を使っても良い
p ary2.sort_by{|x| x.to_i } #=> ["7", "8", "9", "10", "11"]
//}
@see Enumerable#sort_by
, Array#sort_by!... -
Array
# drop _ while {|element| . . . } -> Array (27307.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。 このメソッドは自身を破壊的に変更しません。
...ロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
# 変数aの値は変化しない
a # => [1, 2, 3, 4, 5, 0]
//}
@see Enumerable#drop_while, Array#drop...