るりまサーチ

最速Rubyリファレンスマニュアル検索!
135件ヒット [1-100件を表示] (0.096秒)
トップページ > クエリ:p[x] > クエリ:prepend[x]

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. kernel p
  5. dh p

ライブラリ

クラス

検索結果

<< 1 2 > >>

Module#prepend(*modules) -> self (24273.0)

指定したモジュールを self の継承チェインの先頭に「追加する」ことで self の定数、メソッド、モジュール変数を「上書き」します。

...を処理するため、prependの引数として
渡したモジュールのインスタンスメソッドでsuperを呼ぶことで
self のモジュール/クラスのメソッドを呼び出すことができます。

実際の処理は modules の各要素の prepend_features を後ろから...
...けです。
Module#prepend_features が継承チェインの改変を実行し、結果として上のような
処理が実現されます。そのため、prepend_features を override することで
prepend
の処理を追加/変更できます。


@param modules prepend する Module を指...
...Module#prepend_features, Module#prepended

//emlist[例][ruby]{
# super と prepend の組み合わせの例
module X
def foo
p
uts "X1" # (1x)
super # (2x)
p
uts "X2" # (3x)
end
end

class A
prepend
X

def foo
p
uts "A" #(1a)
end
end

A.new.foo
# (1x) (2x)(ここの super で...

Array#prepend(*obj) -> self (24219.0)

指定された obj を引数の最後から順番に配列の先頭に挿入します。 引数を指定しなければ何もしません。

...@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p
arr #=> [0, 1, 2, 3]
arr.unshift [0]
p
arr #=> [[0], 0, 1, 2, 3]
arr.unshift 1, 2
p
arr #=> [1, 2, [0], 0, 1, 2, 3]
//}

@see Array#pus...
...h, Array#pop, Array#shift...

String#prepend(*arguments) -> String (24215.0)

複数の文字列を先頭に破壊的に追加します。

...複数の文字列を先頭に破壊的に追加します。

@param arguments 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "!!!"
a.prepend # => "!!!"
a # => "!!!"

a = "!!!"
a.prepend "hello ", "world" # => "hello world!!!"
a # => "hello...

String#prepend(other_str) -> String (24210.0)

文字列 other_str を先頭に破壊的に追加します。

...文字列 other_str を先頭に破壊的に追加します。

@param other_str 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "world"
a.prepend("hello ") # => "hello world"
a # => "hello world"
//}...

Module#prepend_features(mod) -> self (12269.0)

Module#prepend から呼び出されるメソッドで、 prepend の処理の実体です。このメソッド自体は mod で指定した モジュール/クラスの継承チェインの先頭に self を追加します。

...Module#prepend から呼び出されるメソッドで、
prepend
の処理の実体です。このメソッド自体は mod で指定した
モジュール/クラスの継承チェインの先頭に self を追加します。

このメソッドを上書きすることで、prepend の処理を変...
...

@param mod prepend を呼び出したモジュール
@return mod が返されます

//emlist[例][ruby]{
class Recorder
RECORDS = []
end

module X
def self.prepend_features(mod)
Recorder::RECORDS << mod
end
end

class A
prepend
X
end

class B
include X
end

class C
prepend
X
en...
...d

Recorder::RECORDS # => [A, C]
//}

@see Module#prepend, Module#prepended...

絞り込み条件を変える

Module#prepended(class_or_module) -> () (12240.0)

self が Module#prepend されたときに対象のクラスまたはモジュールを 引数にしてインタプリタがこのメソッドを呼び出します。

...prepend されたときに対象のクラスまたはモジュールを
引数にしてインタプリタがこのメソッドを呼び出します。

@param class_or_module Module#prepend を実行したオブジェクト

//emlist[例][ruby]{
module A
def self.prepended(mod)
p
uts "#{self} p...
...repended to #{mod}"
end
end
module Enumerable
prepend
A
end
# => "A prepended to Enumerable"
//}

@see Module#included, Module#prepend, Module#prepend_features...

static NODE * arg_prepend(NODE *node1, NODE *node2) (12200.0)

Array#unshift(*obj) -> self (6019.0)

指定された obj を引数の最後から順番に配列の先頭に挿入します。 引数を指定しなければ何もしません。

...@param obj 自身に追加したいオブジェクトを指定します。

//emlist[例][ruby]{
arr = [1,2,3]
arr.unshift 0
p
arr #=> [0, 1, 2, 3]
arr.unshift [0]
p
arr #=> [[0], 0, 1, 2, 3]
arr.unshift 1, 2
p
arr #=> [1, 2, [0], 0, 1, 2, 3]
//}

@see Array#pus...
...h, Array#pop, Array#shift...

NEWS for Ruby 3.0.0 (48.0)

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

...separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Pro...
...cepting a single rest argument and no keywords.
16166

//emlist[][ruby]{
p
r = proc{|*a, **kw| [a, kw]}

p
r.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]

p
r.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwarding (`...`) now suppo...
...out a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-blocking execution context. 16786
* Module
* Module#include and Module#prepend now affect classes and modules that have already included or prepended the receiver, mirroring the behavior if t...

Object#is_a?(mod) -> bool (36.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...します。
Module#includeだけではなく、Object#extendやModule#prepend
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返します。

@param mod クラスやモジュールなど、Moduleかそのサブク...
...です。

//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end

obj = S.new
p
obj.is_a?(S) # true
p
obj.is_a?(C) # true
p
obj.is_a?(Object) # true
p
obj.is_a?(M) # true
p
obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

絞り込み条件を変える

<< 1 2 > >>