るりまサーチ

最速Rubyリファレンスマニュアル検索!
317件ヒット [101-200件を表示] (0.021秒)
トップページ > クエリ:end[x] > クエリ:find[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

検索結果

<< < 1 2 3 4 > >>

パターンマッチ (336.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...を用いて実装されています。

case <expression>
in <pattern1>
...
in <pattern2>
...
in <pattern3>
...
else
...
end


in 節と when 節は1つの case 式の中に混ぜて書くことはできません。

『=>』 演算子と in 演算子で、単体の式で...
...ts "Connect with user '#{user}'"
in connection: {username: }
puts "Connect with user '#{username}'"
else
puts "Unrecognized structure of config"
end

# "Connect with user 'admin'" と出力
//}

一方、『=>』 演算子は、期待されるデータ構造があらかじめ分かっている場...
...パターン: 『[<subpattern>, <subpattern>, <subpattern>, ...]』 (「Array パターン」)
* Find パターン: 『[*variable, <subpattern>, <subpattern>, <subpattern>, ..., *variable]』 (「Find パターン」)
* Hash パターン: 『{key: <subpattern>, key: <subpattern>, ...}』 (「Has...

ruby 1.6 feature (306.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ーになっていました。
((<ruby-dev:17155>))

open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep 1
end

}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)
from -:3...
...-:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-07-30) [i586-linux]
"\\#"
nil

: 2002-04-29: rb_find_file()

$SAFE >= 4 で、絶対パス指定でない場合、SecurityError 例外が発生する
ようになりました。

: 2002-04-26: Reg...
...トで 2 回シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END
{
puts "exit"
}

Thread.start { Thread.stop }
sleep

: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}...

パターンマッチ (270.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...case 文の中で利用できます。

case <expression>
in <pattern1>
...
in <pattern2>
...
in <pattern3>
...
else
...
end


in 節と when 節は1つの case 式の中に混ぜて書くことはできません。


case/in 式は 「網羅的」 です。もし case...
...ts "Connect with user '#{user}'"
in connection: {username: }
puts "Connect with user '#{username}'"
else
puts "Unrecognized structure of config"
end

# "Connect with user 'admin'" と出力
//}

一方、『in』 文は、期待されるデータ構造があらかじめ分かっている場合に...
...mlist[][ruby]{
case [1, 2]
in Integer, Integer
"matched"
else
"not matched"
end

#=> "matched"
//}

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in a: Integer
"matched"
else
"not matched"
end

#=> "matched"
//}




Find
パターン は Array パターン に似ていますが、オブジェク...

Dir.new(path, encoding: Encoding.find("filesystem")) -> Dir (121.0)

path に対するディレクトリストリームをオープンして返します。

...UTF-8>
d.close

d = Dir.new(tmpdir, encoding: Encoding::UTF_8)
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close
end

//}

//emlist[例: Dir.open][ruby]{
require 'tmpdir'

Dir.mktmpdir do |tmpdir|
d = Dir.open(tmpdir, encoding: Encoding::UTF_8)
p d.class...
...# => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close

Dir.open(tmpdir, encoding: Encoding::UTF_8) do |d|
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
end

end

//}...

Dir.open(path, encoding: Encoding.find("filesystem")) -> Dir (121.0)

path に対するディレクトリストリームをオープンして返します。

...UTF-8>
d.close

d = Dir.new(tmpdir, encoding: Encoding::UTF_8)
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close
end

//}

//emlist[例: Dir.open][ruby]{
require 'tmpdir'

Dir.mktmpdir do |tmpdir|
d = Dir.open(tmpdir, encoding: Encoding::UTF_8)
p d.class...
...# => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close

Dir.open(tmpdir, encoding: Encoding::UTF_8) do |d|
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
end

end

//}...

絞り込み条件を変える

Dir.open(path, encoding: Encoding.find("filesystem")) {|dir| ...} -> object (121.0)

path に対するディレクトリストリームをオープンして返します。

...UTF-8>
d.close

d = Dir.new(tmpdir, encoding: Encoding::UTF_8)
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close
end

//}

//emlist[例: Dir.open][ruby]{
require 'tmpdir'

Dir.mktmpdir do |tmpdir|
d = Dir.open(tmpdir, encoding: Encoding::UTF_8)
p d.class...
...# => Dir
p d.read.encoding # => #<Encoding:UTF-8>
d.close

Dir.open(tmpdir, encoding: Encoding::UTF_8) do |d|
p d.class # => Dir
p d.read.encoding # => #<Encoding:UTF-8>
end

end

//}...

ruby 1.8.4 feature (102.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...cket#initialize [bug]>))
* ((<ruby 1.8.4 feature/TCPServer#initialize [bug]>))
* ((<ruby 1.8.4 feature/"optparse">))
* ((<ruby 1.8.4 feature/"find">))
* ((<ruby 1.8.4 feature/Iconv>))
* ((<ruby 1.8.4 feature/WEBrick::Config::FileHandler [compat]>))
* ((<ruby 1.8.4 feature/WEBrick>))
*...
...4 feature/DL [bug]>))
* ((<ruby 1.8.4 feature/fileutils [bug]>))
* ((<ruby 1.8.4 feature/extmk, mkmf [compat]>))
* ((<ruby 1.8.4 feature/mkmf: find_executable() [compat]>))
* ((<ruby 1.8.4 feature/拡張ライブラリAPI>))
* ((<ruby 1.8.4 feature/rb_funcall2() [bug]>))
* ((<ruby 1.8.4 fe...
...適合する文字列を厳密にした。((<ruby-core:03573>)),((<ruby-dev:27478>))

1) alias :"foo" :"bar"

def bar; p "bar"; end
alias :"foo" :"bar"
foo

# => ruby 1.8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpecte...

webrick/cgi (90.0)

一般の CGI 環境で webrick ライブラリのサーブレットと同じように CGI スクリプトを書くための ライブラリです。サーバが WEBrick でなくても使うことが出来ます。

...ebrick/cgi'

class MyCGI < WEBrick::CGI
def do_GET(req, res)
res["content-type"] = "text/plain"
ret = "hoge\n"
res.body = ret
end

end


MyCGI.new.start()

==== do_XXX メソッド

do_XXX メソッドの XXX には GET, HEAD, POST, PUT, DELETE, OPTIONS が使用できます...
...ick::CGI
def do_GET(req, res)
req.query #=> Hash を返します。
req.query['q']
req.query['num']
end

end

MyCGI.new.start()

同じ名前のフィールドが複数ある場合、list メソッドや each_data メソッドを使います。

r...
...es << c2
end

end

MyCGI.new.start()

==== クライアントからクッキーを得る

require "webrick/cgi"
class MyCGI < WEBrick::CGI
def do_GET(req, res)
req.cookies #=> WEBrick::Cookie オブジェクトの配列
c = req.cookies.find{|c| c.n...

NEWS for Ruby 3.0.0 (60.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...> a=>1}, {}]
//}

* Arguments forwarding (`...`) now supports leading arguments.
16378

//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end

//}

* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned. [EXPERIMENTAL]...
...gPatternError
//}

* Find-pattern is added. [EXPERIMENTAL]
16828

//emlist{
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end

//}

* Endless method definition...
...Module
* Module#include and Module#prepend now affect classes and modules that have already included or prepended the receiver, mirroring the behavior if the arguments were included in the receiver before the other modules and classes included or prepended the receiver. 9573
* Module#public,...

NEWS for Ruby 3.1.0 (60.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...数を無名にできるようになりました。 11256

//emlist{
def foo(&)
bar(&)
end

//}

* ピン演算子に式を書けるようになりました。 17411

//emlist{
Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
#=> [[3, 5], [5, 7], [11, 13]]
//}

* ピン演算...
...がインスタンス変数、クラス変数、グローバル変数をサポートしました。 17724

//emlist{
@n = 5
Prime.each_cons(2).lazy.find{_1 in [n, ^@n]}
#=> [3, 5]
//}

* 1行パターンマッチが実験的な機能ではなくなりました。

* 1行パターンマッチが...
...に持つ配列(シングルトンクラスを含まない)を返します。

//emlist[Class#subclasses][ruby]{
class A; end
class B < A; end
class C < B; end
class D < A; end
A.subclasses #=> [D, B]
B.subclasses #=> [C]
C.subclasses #=> []
//}

* Enumerable
* 新規メソッド...

絞り込み条件を変える

Array#pack(template) -> String (48.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}

: エンディアン依存、整数サイズ依存 (C の構造体などに...
...ィアンの強制指定(バイナリ解析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

=== 各テンプレート文字の説明

説明中、Array#p...
...emlist[][ruby]{
require 'socket'
official_hostname, alias_hostnames, address_family, *address_list = Socket.gethostbyname("localhost")
address_list.find {|address| address.size == 4 }.unpack("C4").join(".")
# => "127.0.0.1"

"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x...
<< < 1 2 3 4 > >>