½»»¥Ê½ Ruby Shell irb
irb ÊÇ´ÓÃüÁîÐÐÔËÐеÄ
irb µÄÃüÁîÐÐÑ¡Ïժ×Ô¡¡Porgramming Ruby µÚ¶þ°æ£©
-f
½ûÖ¹¶ÁÈ¡~/.irbrc¡¡Suppress reading ~/.irbrc.
-m
Êýѧģʽ£¨Ö§³Ö·ÖÊýºÍ¾ØÕ󣩡¡Math mode (fraction and matrix support is available).
-d
ÉèÖÃ#DEBUGΪtrue(ͬruby -dÒ»Ñù)¡¡¡¡Set $DEBUG to true (same as ``ruby -d'').
-r load-module
ͬruby -r¡¡Same as ``ruby -r''.
--inspect
ʹÓÃObject#inspectÀ´¸ñʽ»¯Êä³ö£¨Ä¬ÈÏ·½Ê½£¬³ýÊýѧģʽÍ⣩¡¡Use ``inspect'' for output (the default, unless in math mode).
--noinspect
²»Ê¹ÓÃinspect½øÐÐÊä³ö¡¡Do not use inspect for output.
--readline
ʹÓÃReadlineÀ©Õ¹Ä£¿é¡¡Use Readline extension module.
--noreadline
²»Ê¹ÓÃReadlineÀ©Õ¹Ä£¿é¡¡Do not use Readline extension module.
--prompt prompt-mode
Çл»Ìáʾ·û¡£Ô¤¶¨ÒåµÄģʽ°üÀ¨£¨null,default,simple,xmpÒÔ¼°inf-ruby£©¡¡Switch prompt mode. Predefined prompt modes are ``default'', ``simple'', ``xmp'', and ``inf-ruby''.
--prompt-mode prompt-mode
Same as --prompt.
--inf-ruby-mode
ÉèÖÃirbÒÔEmacsµÄinf-ruby-modeģʽÔËÐУ¬¸ü¸ÄÌáʾ·û²¢·ÏÖ¹-readline¡¡Sets up irb to run in inf-ruby-mode under Emacs. Changes the prompt and suppresses --readline.
--simple-prompt
ʹÓüòµ¥µÄÌáʾ·û¡¡Simple prompt mode.
--noprompt
²»ÏÔʾÌáʾ·û¡¡Do not display a prompt.
--tracer
ÏÔʾÃüÁîÖ´Ðеĸú×Ù¡¡Display trace for execution of commands.
--back-trace-limit n
ÏÔʾ×²¿ºÍβ²¿µÄnÏî»ØËÝÐÅÏ¢¡£Ä¬ÈÏֵΪ16¡¡Display backtrace information using the top n and last n entries. The default value is 16.
--irb_debug n
½«ÄÚ²¿µ÷ÊÔ¼¶±ðÉèÖÃΪn(Ö»¶ÔirbµÄ¿ª·¢ÓÐÓã©¡¡Set internal debug level to n (only for irb development).
-v, --version
ÏÔʾirbµÄ°æ±¾ºÅ¡¡Print the version of irb.
ÃüÁîÐпªÊ¼Ö´Ðкó£¬irbÏÔʾһ¸öÌáʾ·û²¢µÈ´ýÊäÈë¡£
ʹÓÃirbµÄĬÈÏÌáʾ·û£¬ËüÏÔʾµ±Ç°µÄ°ó¶¨¡¢Ëõ½ø£¨Ç¶Ì×£©¼¶±ðÒÔ¼°Ðкš£
È磺
C:\>irb
irb(main):001:0> elvuel="elvuel"
=> "elvuel"
irb(main):002:0> elvuel.class
=> String
¿ÉÒÔͨ¹ýexit »ò quit,»òÕßͨ¹ýÊäÈëÒ»¸öÎļþ½áÊø·ûºÅ£¨Èç¹ûûÓÐÉèÖÃIGNORE_EOFģʽ£©À´Í˳ö
Ïà¹ØÎĵµ£º
¹«Ë¾ÀïÔ½À´Ô½¶àµÄ½Ó¿ÚÒÔICE·½Ê½ÌṩÁË£¬ÒÔǰû½Ó´¥¹ý£¬ËùÒÔÎÒÕâÁ½ÌìÒ²³éÁ˵ãʱ¼äÑо¿ÁËÏÂICE£¬²Î¿¼ÁËÍøÉϺܶàÌû×Ó£¬²ÅÖÕÓÚÅÜͨµÚÒ»¸ö¼òµ¥µÄICE
½ÓÏÂÀ´ÌùÉÏÎÒËùÓл·¾³µÄ´î½¨¹ý³ÌÒÔ¼°´úÂ룬ºÍ´ó¼Ò·ÖÏíÏÂICEËù´øÀ´µÄ¿ìÀÖ
ICEÊÇʲôÎҾͲ»¶à˵ÁË
1¡¢ Ò»¿î¸ßÐÔÄܵÄÖмä¼þ£¬»ùÓÚICE¿ÉÒÔʵÏÖµçÐż¶µÄ½ ......
¹ØÓÚC++0x
Ô¤¼ÆÓÚÃ÷Äêµ×ÍƳöµÄбê×¼C++0x£¬Ëä˵ÒѽӽüÊչٽ׶Σ¬È´ÈÔÓÐÈô¸ÉÓдý½ÓÄɵÄÐÂÌá°¸±»Ìá³ö¡£ÓÈÆäÖµµÃ¹Ø×¢µÄÊÇ£¬Óëlambda±í´ïʽÒÔ¼°¾Ö²¿º¯ÊýÏà¹ØµÄÌá°¸“Unified Function Syntax£¨Í³Ò»µÄº¯ÊýÓï·¨£©”£¬¾¡¹Ü²»Êܱê׼ίԱ»á´ý¼û£¨Á½Äê¼äÀú¾ËÄ´ÎÑÓ³Ù±í¾ö£¬Á½´Î²»Óèͨ¹ý£©£¬ÈÔÈ»“ÍçÇ¿µØ”ÍƳöÁ ......
Ëɱ¾ÐкêÈçÔ¼ÓÚÊ¥µ®½Ú·¢²¼ÁËRuby 1.9¡£¸ù¾ÝRubyµÄ¹ßÀý£¬Ð¡ÊýµãºóÃæµÚһλÈç¹ûÊǵ¥Êý£¬ÄÇô¾Í±íÃ÷ÕâÊÇÒ»¸öʵÑé°æ±¾£¬²»ÍƼöÓÃÓÚ²úÆ·»·¾³¡£Ëùν“²úÆ·»·¾³”£¬¶ÔÓÚÄ¿Ç°µÄRubyÀ´Ëµ£¬»ù±¾ÉϾÍÊÇRuby on Rails¡£´ÓÄ¿Ç°RoRÉçȺµÄ·´Ó³À´¿´£¬È·ÊµÓÐÈËÕýÔÚ³¢ÊÔÓÃRuby 1.9ÅäºÏRoR£¬µ«ÊÇÉÐÊô ......
class Tree
def initialize
puts "Make a normal tree"
end
def decorate
puts "Make sure the tree won\'t fall"
end
end
class RedBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Put on some red balls"
end
end
......
ÕÕÀý¿ÉÒÔÏÈ¿´¶Ë³ÌÐò
class Person
def initialize( name,age=18 )
@name = name
@age = age
@motherland = "China"
end
def talk
puts "my name is "+@name+", age is "+@age.to_s
&n ......