34件ヒット
[1-34件を表示]
(0.075秒)
種類
- 文書 (22)
- インスタンスメソッド (12)
ライブラリ
- matrix (12)
クラス
- Vector (12)
キーワード
-
ruby 1
. 6 feature (11) - クラス/メソッドの定義 (11)
検索結果
-
Vector
# []=(index , value) (18112.0) -
index 番目の要素を value に変更します。
...or ベクトルの範囲外にある整数を指定したときに、発生します。
//emlist[][ruby]{
require 'matrix'
v = Vector[0, 0, 0, 0, 0]
v[1] = 2
p v #=> Vector[0, 2, 0, 0, 0]
v[-1] = 3
p v #=> Vector[0, 2, 0, 0, 3]
v[99] = 100
# IndexError: given index 99 is outside of -5...5
//}... -
Vector
# []=(range , v) (18102.0) -
Range オブジェクト range の範囲にある要素を v の内容に置換します。
...Matrix を指定し、次元が合わないときに発生します。
//emlist[][ruby]{
require 'matrix'
v = Vector[0, 0, 0, 0, 0]
v[1..2] = 5
p v #=> Vector[0, 5, 5, 0, 0]
v[1..3] = Vector[2, 4, 8]
p v #=> Vector[0, 2, 4, 8, 0]
v[1..-2] = Matrix[[3, 6, 9]]
p v #=> Vector[0, 3, 6, 9, 0]
//}... -
ruby 1
. 6 feature (5310.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...グ修正がメイン
になります。
((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。
== 1.6.8 (2002-12-24) -> stable-snapshot
: 2003-01-22: errno
EAGAIN と EWOULDBLOCK が同じ値の......!("bar") # <- 以前からこちらは nil を返していた
p "foo".slice!(5,10)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
-:2:in `slice!': index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]......02-06-15 Dir.glob
リンクの切れたシンボリックリンクに対して、Dir.glob がマッチしません
でした。
File.symlink("foo", "bar")
p Dir.glob("bar")
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[]
=> ruby 1.6.7 (2002-08-01) [i586-li... -
クラス/メソッドの定義 (102.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...い場合は nil を返します。
===[a:method] メソッド定義
//emlist[例][ruby]{
def fact(n)
if n == 1 then
1
else
n * fact(n-1)
end
end
//}
文法:
def メソッド名 ['(' [arg0 ['=' default0]] ... [',' '*' rest_args [, post ...]] [',' key1: [val1]] ... [',' '*......2番目の引数yにデフォルト値を指定
10 * x + y
end
p foo(1, 5) #=> 15
p foo(3) #=> 31
p foo #=> ArgumentError (wrong number of arguments)
//}
デフォルト値を指定する引数の位置は、1つの連続した区間になっている必要があります。
(デフ......er
def -(other); end # obj - other
# 単項プラス/マイナス
def +@; end # +obj
def -@; end # -obj
# 要素代入
def foo=(value); end # obj.foo = value
# [] と []=
def [](key); end # obj[key]
def []=(key,...