システムのエンディアンを表示する。
設問
Write a program to print out the endianness of the system.
Print to stdout, the endianness, wheather it is LittleEndian or BigEndian.
やってみた
packを使うんだろうなというのは、なんとななく頭にあったので
ググると
packテンプレート文字列 - Rubyリファレンスマニュアル
に書かれてあった。
#!/usr/bin/env ruby system, big, little = %w(s2, n2, v2).map{ |tpl| [1,2].pack tpl } case system when big; puts 'BigEndian' when little; puts 'LittleEndian' end