2008-08-31から1日間の記事一覧

ActiveSupport、String#squish, String#squish!

まんま >> require "rubygems" => true >> require "active_support" => true >> s = " foo bar \n \t boo" => " foo bar \n \t boo" >> s.squish => "foo bar boo" >> s.squish! => "foo bar boo" >> s => "foo bar boo"

JDK5.0 新機能:EnumSet.range

「4.6. EnumSet」 import java.util.*; enum C2008083100_Color { RED, BLUE, YELLOW, BLACK, WHITE } public class C2008083100 { public static void main(String[] args) { EnumSet<C2008083100_Color> s; s = EnumSet.range(C2008083100_Color.RED, C2008083100_Color.WHITE</c2008083100_color>…

サブ規則の引数リスト 複数渡せる

#!/usr/bin/env perl use strict; use Parse::RecDescent; my $grammar = q{ inputs : rule['foo', 'bar', 'baz'] rule : 'a' { print "$arg[0] $arg[1] $arg[2]\n"; } }; my $parse = new Parse::RecDescent ($grammar); while (<>) { defined $parse->inpu…

os.exit

元 exit ? #!/usr/bin/env lua os.exit(0) で、 $ ./2008083100.lua $ echo $? 0#!/usr/bin/env lua os.exit(1) で、 $ ./2008083101.lua $ echo $? 1