#์ค์นผ๋ผ stable identifier
def f(x: Int, y: Int) = x match { case `y` => ... }
Now, the pattern matches the y
parameter of the enclosing function f
. That is, the match succeeds only if the x
argument and the y
argument of f
are equal
def getFieldValueFromJson(jsonString: String, fieldName: String): Option[Json] = {
jsonString.fromJson[Json] match {
case Right(Json.Obj(fields)) => fields.collectFirst { case (`fieldName`, v) => v }
case _ => None
}
}
// find + map์ collectFirst๋ก ๋ฐ๊ฟ ์ ์๋ค.
๋ฐฐ์ด ๊ฒ
from. sean
๋ด๊ฐ ๋ณ๊ฒฝํ๊ณ ์ถ์ ๋ถ๋ถ์ ๋น ๋ฅด๊ฒ ์ฐพ๋ ๋ฒ
- ์ฐ์ ํน์ ํจ์๊ฐ ์ํํ ๊ฒ์ด๋ผ๊ณ ๊ธฐ๋ํ๋ ๊ฒ์ด ๋ช ํํด์ผ ํจ
- ํจ์ ์ค์ฝํ ๋จ์๋ก ํ์ ํด์ ๋ชจ๋ฅด๋ ๋ถ๋ถ์ ์ถ์ํํด์ผ ํจ
- ๋ง์ฝ ํด๋น ์ค์ฝํ๊ฐ ์๋๋ผ๋ฉด ๋น ๋ฅด๊ฒ ํจ์๋ฅผ ํธ์ถํ๋ ๋ถ๋ถ์ผ๋ก ๋์ด๊ฐ๊ธฐ
- ๋๋ ํจ์๊ฐ ์ฌ๋ฌ ๊ณณ์์ ํธ์ถ๋๋ค๋ฉด ์์๋๋ก ํ์ํ๊ธฐ
chatGPT์๊ฒ ๊ด๋ จ context ์ค๋ช ํ๋ ๋ฐฉ๋ฒ ๋ฆฌํฉํ ๋ง ํ๋ ค๊ณ ํ ๋ ๋ฌด์ง์ฑ์ผ๋ก ๋ณต๋ถํ์ง ๋ง๊ณ ์๋ณธ ์ฝ๋๊ฐ ์ด๋ค ์๋ฏธ๋ฅผ ๊ฐ์ก๋ ์ง ํ์ ํ ํ ๋ณต๋ถํ ๊ณณ์ ํ์ํ๋ค