everyday
説明はなかったが、ファイル作成すると以下のコードが挿入されていた。 puts "Hello, RubyPico!" puts "http://rubypico.ongaeshi.me" puts Image.load("chat_ruby.png") これは消して実行すると irb - Interactive Ruby Shell irb:000> load "greeter" => t…
irb - Interactive Ruby Shell irb:000> def hello; puts "Hello World!"; end => :hello irb:001> hello Hello World! => nil irb:002> def hello line 1: syntax error, unexpected $end, expecting ';' or '\n' irb:003> CRubyだと >> def hello >> puts …
「irbで変数を使うときは@を付ける」 irb - Interactive Ruby Shell irb:000> x = 1 => 1 irb:001> x undefined method 'x' for main irb:002> @x = 1 => 1 irb:003> @x => 1 irb:004> 理由不明
irb - Interactive Ruby Shell irb:000> 1 + 1 => 2 irb:001>
WScript.Echo([1, 2, 3].valueOf());
WScript.Echo(Date.UTC(2012, 6, 26)); WScript.Echo(Date.UTC(1970, 0, 1, 0, 0, 0, 1));
WScript.Echo(unescape("*" + "%20" + "*")); WScript.Echo(unescape("%u3042")); // あ
まんま <HEAD> <SCRIPT LANGUAGE="VBScript"> <!-- Function CreateVBArray() Dim i, j, k Dim a(2, 2) k = 1 For i = 0 To 2 For j = 0 To 2 a(j, i) = k k = k + 1 Next Next CreateVBArray = a End Function --> </SCRIPT> <SCRIPT LANGUAGE="JScript"> </head>
WScript.Echo(new Date().toUTCString()); WScript.Echo(new Date().toString());
WScript.Echo("abc".toUpperCase());
WScript.Echo(new Date().toString()); WScript.Echo(true); WScript.Echo(true.toString()); //WScript.Echo(1.toString()); x = 10; WScript.Echo(x.toString()); WScript.Echo(x.toString(2)); WScript.Echo(x.toString(16));
WScript.Echo("ABC".toLowerCase());
WScript.Echo(new Date().toLocaleString());
WScript.Echo(new Date().toGMTString());
まんま <HEAD> <SCRIPT LANGUAGE="VBScript"> <!-- Function CreateVBArray() Dim i, j, k Dim a(2, 2) k = 1 For i = 0 To 2 For j = 0 To 2 a(j, i) = k document.writeln(k) k = k + 1 Next document.writeln("<BR>") Next CreateVBArray = a End Function --> </SCRIPT> <SCRIPT LANGUAGE="JScript"> </head>
WScript.Echo(/\w/.test("foo")); if (/\w/.test("foo")) { WScript.Echo("then"); } else { WScript.Echo("else"); } WScript.Echo(/\d/.test("foo"));
WScript.Echo(Math.tan(0)); WScript.Echo(Math.tan(Math.PI/4));
WScript.Echo("foo".sup());
substr, substring というちょっと紛らわしい使い分け… WScript.Echo("foo".substring(0,1)); WScript.Echo("foo".substring(1,0)); WScript.Echo("foo".substring(0,0)); WScript.Echo("foo".substring(4,5)); WScript.Echo("foo".substring(-1,1));
WScript.Echo("foo bar".substr(0)); WScript.Echo("foo bar".substr(1)); WScript.Echo("foo bar".substr(1, 4)); WScript.Echo("foo bar".substr(1, 10)); WScript.Echo("foo bar".substr(10)); WScript.Echo("foo bar".substr(1, -1));
WScript.Echo("foo".sub());
WScript.Echo("foo".strike());
WScript.Echo(Math.sqrt(2));
a = "abc def ghi".split(/\s+/); WScript.Echo(a); a = "abc def ghi".split(/\s+/, 1); WScript.Echo(a);
a = [3, 4, 2, 1] WScript.Echo(a.sort()); WScript.Echo(a); a.sort(function(a, b) { if (a > b) { return -1; } else if (a < b) { return 1; } else { return 0; } }); WScript.Echo(a);
WScript.Echo("foo".small());
str = "abc" WScript.Echo(str.slice(0)); WScript.Echo(str.slice(1)); WScript.Echo(str.slice(3)); WScript.Echo(str.slice(0,1)); WScript.Echo(str.slice(1,0)); WScript.Echo(str.slice(-1)); WScript.Echo(str.slice(-2,-1)); WScript.Echo(str.slice…
a = [1, 2, 3] WScript.Echo(a.slice(0)); WScript.Echo(a.slice(1)); WScript.Echo(a.slice(3)); WScript.Echo(a.slice(0,1)); WScript.Echo(a.slice(1,0)); WScript.Echo(a.slice(-1)); WScript.Echo(a.slice(-2,-1)); WScript.Echo(a.slice(-2)); WScript…
WScript.Echo(Math.sin(0)); WScript.Echo(Math.sin(Math.PI/2));
d = new Date(); WScript.Echo(d); d.setYear(2011); WScript.Echo(d);