スマートフォン用の表示で見る

try ruby!

ウェブ

try ruby!

とらいるびー

no title no title

WebブラウザだけでRubyを学ぶ - まちゅダイアリー(2005-12-03)

http://static.flickr.com/18/69502359_dbb6513e04.jpg

プログラミング言語 Ruby リファレンスマニュアル

no title

>> 1 + 2

=> 3

>> 5 * 5

=> 25

>> -5.abs

=> 5

>> -5.type

=> Fixnum

>> -5.abs.to_s

=> "5"

>> 10.divmod(3)

=> [3, 1]

>> 10.divmod(3)[0].to_s

=> "3"

>> 10.divmod(3)[1].to_s

=> "1"

>> Time.now

=> Mon Dec 24 00:10:30 CST 2005

>> Time.now.to_s

=> "Mon Dec 24 00:10:45 CST 2005"

>> a = [0,1,2]

=> [0, 1, 2]

>> a.type

=> Array

>> a.shift

=> 0

>> a

=> [1, 2]

>> a.unshift 0

=> [0, 1, 2]

>> a

=> [0, 1, 2]

>> a.last.to_s

=> "2"

>> a.reverse

=> [2, 1, 0]

>> a.clear

=> []

>> a

=> []

>> a.methods

=> ["send", "compact", "rindex", "reject", "[]=", "<<", "last", "&", "object_id"

, "join", "delete_if", "size", "singleton_methods", "__send__", "member?", "each

_index", "equal?", "taint", "sort!", "assoc", "*", "find", "instance_variable_ge

t", "each_with_index", "frozen?", "to_ary", "+", "kind_of?", "slice!", "instance

_eval", "to_a", "-", "replace", "collect", "push", "reverse", "all?", "method",

"entries", "type", "protected_methods", "extend", "pack", "reverse_each", "colle

ct!", "rassoc", "|", "detect", "eql?", "at", "compact!", "zip", "instance_variab

le_set", "hash", "is_a?", "reject!", "empty?", "flatten", "map", "to_s", "any?",

"pop", "class", "transpose", "sort", "tainted?", "private_methods", "min", "ind

exes", "untaint", "find_all", "map!", "uniq", "each", "fetch", "id", "reverse!",

"values_at", "insert", "display", "inject", "<=>", "inspect", "delete", "==", "

shift", "concat", "===", "clear", "sort_by", "clone", "public_methods", "max", "

indices", "respond_to?", "index", "select", "freeze", "slice", "first", "flatten

!", "__id__", "delete_at", "length", "=~", "methods", "nitems", "partition", "un

shift", "nil?", "dup", "fill", "grep", "instance_variables", "uniq!", "include?"

, "instance_of?", "[]"]

>> fruit = {"banana" => "yellow","apple" => "red"}

=> {"apple"=>"red", "banana"=>"yellow"}

>> fruit.type

=> Hash

>> fruit["apple"]

=> "red"

>> fruit["banana"]

=> "yellow"

>> fruit.max

=> ["banana", "yellow"]

>> fruit.max.max

=> "yellow"

>> fruit.invert

=> {"red"=>"apple", "yellow"=>"banana"}

>> fruit2 = fruit.invert

=> {"red"=>"apple", "yellow"=>"banana"}

>> fruit.methods

=> ["reject", "[]=", "send", "each_pair", "object_id", "merge!", "delete_if", "s

ize", "singleton_methods", "__send__", "merge", "member?", "equal?", "taint", "f

ind", "frozen?", "instance_variable_get", "each_with_index", "store", "kind_of?"

, "instance_eval", "to_a", "replace", "collect", "values", "all?", "entries", "m

ethod", "type", "default", "protected_methods", "extend", "detect", "eql?", "def

ault=", "default_proc", "zip", "instance_variable_set", "hash", "is_a?", "reject

!", "empty?", "map", "to_s", "invert", "any?", "class", "sort", "has_key?", "tai

nted?", "private_methods", "key?", "min", "indexes", "untaint", "find_all", "key

s", "each_value", "each", "fetch", "id", "values_at", "inject", "inspect", "dele

te", "display", "==", "shift", "update", "===", "clear", "sort_by", "has_value?"

, "clone", "public_methods", "rehash", "max", "indices", "respond_to?", "index",

"select", "freeze", "each_key", "length", "__id__", "partition", "=~", "methods

", "nil?", "grep", "value?", "dup", "to_hash", "instance_variables", "include?",

"[]", "instance_of?"]