This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| session.beginTransaction(); | |
| cat = session.get(Cat.class, 1L); | |
| cat.setName("Charlie"); | |
| session.getTransaction().commit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> let selectBestMovie = ({ starwars: [ first, second, third, ...rest ]}) | |
| => ({ best: second }) | |
| >> selectBestMovie({ | |
| starwars: [ | |
| 'A New Hope', | |
| 'The Empire Strikes Back', | |
| 'Return of the Jedi' | |
| ] | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> makeItRight({ | |
| starwars: { | |
| han: { shotfirst: false }, | |
| greedo: { shotfirst: true } | |
| } | |
| }) | |
| <- { | |
| starwars: { | |
| han: { shotfirst: true }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> let makeItRight = | |
| ({ starwars: | |
| { | |
| han: { shotfirst: hanShotFirst }, | |
| greedo: { shotfirst: greedoShotFirst } | |
| } | |
| }) => | |
| ({ starwars: | |
| { | |
| han: { shotfirst: greedoShotFirst }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> let extractFruit = ({ container: { box: { fruit } } }) | |
| => ({ fruit }) | |
| >> extractFruit({ container: { box: { fruit: "apple" } } }) | |
| <- Object { fruit: "apple" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> let wrongExtract = ({ fruit }) => { fruit } | |
| <- undefined | |
| >> wrongExtract({fruit: "apple"}) | |
| <- undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> extract({ fruit: "apple", "color": "red" }) | |
| <- Object { fruit: "apple" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> extract({ fruit: "apple" }) | |
| <- Object { fruit: "apple" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let extract = ({ fruit }) => ({ fruit }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ParameterizedTest | |
| @MethodSource("source") | |
| public void test(TestCase testCase) { | |
| Assertions.assertEquals( | |
| testCase.expected, | |
| new Problem().check(testCase.target, testCase.array) | |
| ); | |
| } |