From: Takaaki Tateishi Date: 2005-10-18T04:12:17+09:00 Subject: Re: Ruby/DL union! method syntax gregarican wrote: > I read the Ruby/DL docs on using the struct! method and have an > understanding about it. How about the union! method? I have googled > around and can't find any examples of its use. The following test code > doesn't seem to work: > -------------------------- > require 'dl' > thisStruct=DL.malloc(4) > thisStruct.struct!('L', :longPointer) > thatStruct=DL.malloc(2) > thatStruct.struct!('H', :shortPointer) > theUnion=DL.malloc(6) > theUnion.union!(thisStruct, thatStruct) You should pass a signature and labels like struct!. theUnion.union!('LH', :long, :short) theUnion[:long] = 2**16 p theUnion[:long] # => 65536 p theUnion[:short] # => 0 -- Takaaki Tateishi