Skip to content

Commit 382f65e

Browse files
authored
Merge pull request #725 from Philippus/issue/string-interpolation-fix
fix example on string-interpolation page
2 parents d546dd2 + f534689 commit 382f65e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

es/overviews/core/string-interpolation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ En este ejemplo, estamos intentando crear una cadena JSON mediante el uso de la
102102

103103
Cuando el compilador encuentra la cadena `json"{ name: $name, id: $id }"` reescribe la siguiente expresión:
104104

105-
new StringContext("{ name:", ",id: ", "}").json(name, id)
105+
new StringContext("{ name: ", ", id: ", " }").json(name, id)
106106

107107
La clase implícita es utilizada para reescribir el fragmento anterior de la siguiente forma:
108108

109-
new JsonHelper(new StringContext("{ name:", ",id: ", "}")).json(name, id)
109+
new JsonHelper(new StringContext("{ name: ", ", id: ", " }")).json(name, id)
110110

111111
De este modo, el método `json` tiene acceso a las diferentes partes de las cadenas así como cada una de las expresiones. Una implementación simple, y con errores, de este método podría ser:
112112

ja/overviews/core/string-interpolation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ Scala では、全ての加工文字列リテラルは簡単なコード変換
101101

102102
コンパイラが `json"{ name: $name, id: $id }"` を見つけると、以下の式に書き換える:
103103

104-
new StringContext("{ name:", ",id: ", "}").json(name, id)
104+
new StringContext("{ name: ", ", id: ", " }").json(name, id)
105105

106106
さらに、implicit クラスは以下のように書き換える:
107107

108-
new JsonHelper(new StringContext("{ name:", ",id: ", "}")).json(name, id)
108+
new JsonHelper(new StringContext("{ name: ", ", id: ", " }")).json(name, id)
109109

110110
そのため、`json` メソッドは生の String 部分と渡される式の値をみることができる。シンプルな (だけどバギーな) 実装を以下に示す:
111111

overviews/core/_posts/2012-09-21-string-interpolation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ In this example, we're attempting to create a JSON literal syntax using string i
112112

113113
When the compiler encounters the literal `json"{ name: $name, id: $id }"` it rewrites it to the following expression:
114114

115-
new StringContext("{ name:", ",id: ", "}").json(name, id)
115+
new StringContext("{ name: ", ", id: ", " }").json(name, id)
116116

117117
The implicit class is then used to rewrite it to the following:
118118

119-
new JsonHelper(new StringContext("{ name:", ",id: ", "}")).json(name, id)
119+
new JsonHelper(new StringContext("{ name: ", ", id: ", " }")).json(name, id)
120120

121121
So, the `json` method has access to the raw pieces of strings and each expression as a value. A simple (buggy) implementation of this method could be:
122122

0 commit comments

Comments
 (0)