以下の内容はhttps://tbpgr.hatenablog.com/entry/20141215/1418648810より取得しました。


Ruby | String | bytes

概要

String#bytes -> [Integer]
String#bytes {|byte| ... } -> self

詳細

文字列の各バイトを数値の配列で返却。(self.each_byte.to_a と同じです)
ブロック版のインターフェースは obsolete (廃止) のため String#each_block を利用すること

サンプルコード
require 'tbpgr_utils'


bulk_puts_eval binding, <<-EOS
'hoge'.bytes
tmp = []
'hoge'.bytes { |e|tmp << (e + 1).chr }
tmp
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

'hoge'.bytes                           # => [104, 111, 103, 101]
tmp = []                               # => []
'hoge'.bytes { |e|tmp << (e + 1).chr } # => "hoge"
tmp                                    # => ["i", "p", "h", "f"]



以上の内容はhttps://tbpgr.hatenablog.com/entry/20141215/1418648810より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14