teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

5

補足

2017/02/15 09:15

投稿

退会済みユーザー
answer CHANGED
@@ -18,4 +18,5 @@
18
18
  ```Ruby
19
19
  tmp = '0804a060'
20
20
  tmp.scan(/.{1,2}/).each{|e| print '\\x' + e}
21
- ```
21
+ ```
22
+ mapで配列の中身を入れ替えて最後にjoinで要素をくっつけてprintしています。

4

修正

2017/02/15 09:15

投稿

退会済みユーザー
answer CHANGED
@@ -17,5 +17,5 @@
17
17
  バラバラのまま出力
18
18
  ```Ruby
19
19
  tmp = '0804a060'
20
- tmp.scan(/.{1,2}/).map{|e| print '\\x' + e}
20
+ tmp.scan(/.{1,2}/).each{|e| print '\\x' + e}
21
21
  ```

3

補足

2017/02/15 09:02

投稿

退会済みユーザー
answer CHANGED
@@ -7,3 +7,15 @@
7
7
  [rubyのprint / puts / p の違い](http://qiita.com/shoma2da/items/b2c92c6556858a4722b3)
8
8
 
9
9
  putsかprintを使うと"\\"は"\"として表示されます。
10
+
11
+ #補足
12
+ くっつけて出力
13
+ ```Ruby
14
+ tmp = '0804a060'
15
+ print tmp.scan(/.{1,2}/).map{|e| '\\x' + e}.join
16
+ ```
17
+ バラバラのまま出力
18
+ ```Ruby
19
+ tmp = '0804a060'
20
+ tmp.scan(/.{1,2}/).map{|e| print '\\x' + e}
21
+ ```

2

修正

2017/02/15 08:59

投稿

退会済みユーザー
answer CHANGED
@@ -4,4 +4,6 @@
4
4
  ```Ruby
5
5
  print "\\"
6
6
  ```
7
- [rubyのprint / puts / p の違い](http://qiita.com/shoma2da/items/b2c92c6556858a4722b3)
7
+ [rubyのprint / puts / p の違い](http://qiita.com/shoma2da/items/b2c92c6556858a4722b3)
8
+
9
+ putsかprintを使うと"\\"は"\"として表示されます。

1

補足

2017/02/14 17:00

投稿

退会済みユーザー
answer CHANGED
@@ -1,3 +1,7 @@
1
1
  ```Ruby
2
2
  puts "\\"
3
- ```
3
+ ```
4
+ ```Ruby
5
+ print "\\"
6
+ ```
7
+ [rubyのprint / puts / p の違い](http://qiita.com/shoma2da/items/b2c92c6556858a4722b3)