2008-11-29から1日間の記事一覧

ActiveSupport、Date#advance

>> require "rubygems" => true >> require "active_support" => true >> Date.new(2008, 12, 31).advance(:years => 1) => Thu, 31 Dec 2009 >> Date.new(2008, 2, 29).advance(:years => 1) => Sat, 28 Feb 2009 >> Date.new(2008, 12, 31).advance(:years…

Commons Lang、StringUtils.substringBefore()

ほぼ、まんま import org.apache.commons.lang.StringUtils; public class C2008112900 { public static void main(String[] args) { System.out.println(StringUtils.substringBefore(null, "z")); System.out.println(StringUtils.substringBefore("", "z"…

Parsec.Token:operator

module Main where import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Token import Text.ParserCombinators.Parsec.Language lexer :: TokenParser () lexer = makeTokenParser(javaStyle) run :: Show a => Parser a -> String …

setmetatable()

#!/usr/bin/env lua t = { "foo", "bar", "baz" } print(t.__metatable) setmetatable(t, {}) setmetatable(t, nil) mt = {} mt.__metatable = function(x) end setmetatable(t, mt) setmetatable(t, nil) で、 nil lua: ./2008112900.lua:15: cannot change…