Friday, May 18, 2012

Difference between Struck and OpenStruct

Ruby has two structure classes - Struct and OpenStruct.

Struct

This is the normal struct.
  • Generated struct is dealt as constant.
  • Accessor methods are not dynamic.
[1] pry(main)> Foo = Struct.new('Foo', :bar, :baz)
=> Struct::Foo
[2] pry(main)> foo = Foo.new(1, 2)
=> #<struct Struct::Foo bar=1, baz=2>
[3] pry(main)> foo.bar = 3
=> 3
[4] pry(main)> foo
=> #<struct Struct::Foo bar=3, baz=2>
[5] pry(main)> foo.qux = 4
NoMethodError: undefined method `qux=' for #<struct Struct::Foo bar=3, baz=2>
from (pry):5:in `<main>'

OpenStruct

This is dynamic struct.
  • Generated struct is dealt as variable.
  • Accessor methods are dynamic.
[1] pry(main)> require 'ostruct'
=> false
[2] pry(main)> foo = OpenStruct.new(bar:1,baz:2)
=> #<OpenStruct bar=1, baz=2>
[3] pry(main)> foo.bar = 3
=> 3
[4] pry(main)> foo
=> #<OpenStruct bar=3, baz=2>
[5] pry(main)> foo.qux = 4
=> 4
[6] pry(main)> foo
=> #<OpenStruct bar=3, baz=2, qux=4>

Tuesday, May 15, 2012

PostgreSQL Magazine has been launched

About 1 week ago, PostgreSQL Magazine has been launched and #1 has been issued. This is the nice e-book magazine, and I want to convert to PostgreSQL from MySQL and its any forks.

Saturday, May 12, 2012

QtCreator never supports MinGW anymore (and Qt maybe too.)

3 days ago, QtCreator 2.5.0 has been released. But, this release contains sad news. Since 2.5, QtCreator never supports MinGW anymore. And IMO, Qt runtime maybe follow, because current download page of Qt runtime still contains MinGW runtime binary, but does not contain any links to MinGW zip exited.

Thursday, May 10, 2012

Java7u4 enables G1GC without UnlockExperimentalVMOptions

(via http://www.infoq.com/news/2012/05/java7u4)

A week ago, Java7u4 has been released. The most notable change is we can enable G1GC without UnlockExperimentalVMOptions.
> java -XX:+UseG1GC Another args...
or,
JAVA_OPTS="-XX:+UseG1GC"
> java $JAVA_OPTS Another args...

Monday, May 7, 2012

Start reading "Programming Microsoft ASP.NET MVC, Second Edition"

I have started reading the Japanese edition of "Programming Microsoft® ASP.NET MVC, Second Edition".


The cover of English edition is below:

But, Japanese edition contains the great appendix - about ASP.NET MVC 4.