Skip to content

Instantly share code, notes, and snippets.

session.beginTransaction();
cat = session.get(Cat.class, 1L);
cat.setName("Charlie");
session.getTransaction().commit();
>> let selectBestMovie = ({ starwars: [ first, second, third, ...rest ]})
=> ({ best: second })
>> selectBestMovie({
starwars: [
'A New Hope',
'The Empire Strikes Back',
'Return of the Jedi'
]
})
>> makeItRight({
starwars: {
han: { shotfirst: false },
greedo: { shotfirst: true }
}
})
<- {
starwars: {
han: { shotfirst: true },
>> let makeItRight =
({ starwars:
{
han: { shotfirst: hanShotFirst },
greedo: { shotfirst: greedoShotFirst }
}
}) =>
({ starwars:
{
han: { shotfirst: greedoShotFirst },
>> let extractFruit = ({ container: { box: { fruit } } })
=> ({ fruit })
>> extractFruit({ container: { box: { fruit: "apple" } } })
<- Object { fruit: "apple" }
>> let wrongExtract = ({ fruit }) => { fruit }
<- undefined
>> wrongExtract({fruit: "apple"})
<- undefined
>> extract({ fruit: "apple", "color": "red" })
<- Object { fruit: "apple" }
>> extract({ fruit: "apple" })
<- Object { fruit: "apple" }
let extract = ({ fruit }) => ({ fruit })
@forketyfork
forketyfork / ProblemTest.java
Created April 21, 2020 06:38
JUnit 5 with Records - parameterized test
@ParameterizedTest
@MethodSource("source")
public void test(TestCase testCase) {
Assertions.assertEquals(
testCase.expected,
new Problem().check(testCase.target, testCase.array)
);
}