Skip to content

Commit ee33bcd

Browse files
committed
Update idiomatic notebook for Paris JUG and add Hello class with message handling
1 parent a20467f commit ee33bcd

File tree

3 files changed

+63
-39
lines changed

3 files changed

+63
-39
lines changed

material/conferences/2024-11-12-paris-jug/idiomatic-01.ipynb

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@
55
"cell_type": "markdown",
66
"source": [
77
"# Idiomatic Kotlin @ Paris JUG\n",
8-
"Date: 2024 / 10 / 12"
8+
"Date: 2024 / 11 / 12"
99
]
1010
},
1111
{
12-
"cell_type": "code",
1312
"metadata": {
1413
"collapsed": true,
1514
"ExecuteTime": {
16-
"end_time": "2024-10-25T14:33:51.646533Z",
17-
"start_time": "2024-10-25T14:33:51.606114Z"
15+
"end_time": "2024-11-12T08:46:52.080221800Z",
16+
"start_time": "2024-11-12T08:46:51.711403Z"
1817
}
1918
},
20-
"source": [
21-
"val event = \"Paris JUG\"\n",
22-
"println(\"Hello $event\") // String template"
23-
],
19+
"cell_type": "code",
2420
"outputs": [
2521
{
2622
"name": "stdout",
@@ -30,24 +26,20 @@
3026
]
3127
}
3228
],
33-
"execution_count": 17
29+
"execution_count": 1,
30+
"source": [
31+
"val event = \"Paris JUG\"\n",
32+
"println(\"Hello $event\") // String template"
33+
]
3434
},
3535
{
3636
"metadata": {
3737
"ExecuteTime": {
38-
"end_time": "2024-10-25T14:33:51.733128900Z",
39-
"start_time": "2024-10-25T14:33:51.666925500Z"
38+
"end_time": "2024-11-12T08:46:52.606006400Z",
39+
"start_time": "2024-11-12T08:46:52.182420600Z"
4040
}
4141
},
4242
"cell_type": "code",
43-
"source": [
44-
"// Extension function: add a function to a class without inhetitance\n",
45-
"fun String.randomCase(): String {\n",
46-
" // If expression\n",
47-
" return if (Math.random() > 0.5) uppercase() else lowercase()\n",
48-
"}\n",
49-
"println(event.randomCase())"
50-
],
5143
"outputs": [
5244
{
5345
"name": "stdout",
@@ -57,13 +49,21 @@
5749
]
5850
}
5951
],
60-
"execution_count": 18
52+
"execution_count": 2,
53+
"source": [
54+
"// Extension function: add a function to a class without inhetitance\n",
55+
"fun String.randomCase(): String {\n",
56+
" // If expression\n",
57+
" return if (Math.random() > 0.5) uppercase() else lowercase()\n",
58+
"}\n",
59+
"println(event.randomCase())"
60+
]
6161
},
6262
{
6363
"metadata": {
6464
"ExecuteTime": {
65-
"end_time": "2024-10-25T14:33:51.861854200Z",
66-
"start_time": "2024-10-25T14:33:51.755062200Z"
65+
"end_time": "2024-11-12T20:11:18.362206600Z",
66+
"start_time": "2024-11-12T20:11:18.090413800Z"
6767
}
6868
},
6969
"cell_type": "code",
@@ -75,8 +75,9 @@
7575
"// Argument labels\n",
7676
"println(event.randomCaseChance(offset = 3))\n",
7777
"println(event.randomCaseChance(\n",
78-
" chance = 0.9,\n",
78+
" \n",
7979
" offset = 2,\n",
80+
" chance = 0.9,\n",
8081
" )\n",
8182
")"
8283
],
@@ -90,13 +91,13 @@
9091
]
9192
}
9293
],
93-
"execution_count": 19
94+
"execution_count": 10
9495
},
9596
{
9697
"metadata": {
9798
"ExecuteTime": {
98-
"end_time": "2024-10-25T14:33:52.069576Z",
99-
"start_time": "2024-10-25T14:33:51.987387600Z"
99+
"end_time": "2024-11-12T08:46:53.633203200Z",
100+
"start_time": "2024-11-12T08:46:53.337385800Z"
100101
}
101102
},
102103
"cell_type": "code",
@@ -118,13 +119,13 @@
118119
]
119120
}
120121
],
121-
"execution_count": 20
122+
"execution_count": 4
122123
},
123124
{
124125
"metadata": {
125126
"ExecuteTime": {
126-
"end_time": "2024-10-25T14:33:52.233616600Z",
127-
"start_time": "2024-10-25T14:33:52.158182800Z"
127+
"end_time": "2024-11-12T08:46:53.984086300Z",
128+
"start_time": "2024-11-12T08:46:53.673347200Z"
128129
}
129130
},
130131
"cell_type": "code",
@@ -145,13 +146,13 @@
145146
]
146147
}
147148
],
148-
"execution_count": 21
149+
"execution_count": 5
149150
},
150151
{
151152
"metadata": {
152153
"ExecuteTime": {
153-
"end_time": "2024-10-25T14:40:24.001881Z",
154-
"start_time": "2024-10-25T14:40:23.881908900Z"
154+
"end_time": "2024-11-12T08:46:54.593211500Z",
155+
"start_time": "2024-11-12T08:46:54.027803300Z"
155156
}
156157
},
157158
"cell_type": "code",
@@ -170,18 +171,18 @@
170171
"name": "stdout",
171172
"output_type": "stream",
172173
"text": [
173-
"P, a, r, I, S, , J, u, g\r\n",
174+
"p, A, R, i, S, , j, u, G\r\n",
174175
"[P/2, a/0, r/2, i/4]\r\n"
175176
]
176177
}
177178
],
178-
"execution_count": 24
179+
"execution_count": 6
179180
},
180181
{
181182
"metadata": {
182183
"ExecuteTime": {
183-
"end_time": "2024-10-25T14:50:19.815828200Z",
184-
"start_time": "2024-10-25T14:50:19.702384500Z"
184+
"end_time": "2024-11-12T08:46:55.067201900Z",
185+
"start_time": "2024-11-12T08:46:54.610120800Z"
185186
}
186187
},
187188
"cell_type": "code",
@@ -212,7 +213,7 @@
212213
]
213214
}
214215
],
215-
"execution_count": 27
216+
"execution_count": 7
216217
}
217218
],
218219
"metadata": {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package javafxdemo.app.src.main.java.org.example;
2+
3+
public class Hello {
4+
// In Kotlin -> (message: String)
5+
public void sayHelloNonNull(@Nonnull String message) {
6+
System.out.println(message);
7+
}
8+
9+
// In Kotlin -> (message: String?)
10+
public void sayHelloNullable(@Nullable String message) {
11+
System.out.println(message != null ? message.toUpperCase() : "null");
12+
}
13+
14+
// In Kotlin -> (message: String!) (! means that message can be String? or String)
15+
public void sayHello(String message) {
16+
System.out.println(message);
17+
}
18+
}
19+

material/conferences/2024-11-12-paris-jug/javafxdemo/app/src/main/kotlin/org/example/App.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package org.example
22

33
import javafx.application.Application
4-
import javafx.geometry.HPos
54
import javafx.stage.Stage
65
import ktfx.coroutines.onAction
7-
import ktfx.dialogs.infoAlert
86
import ktfx.launchApplication
97
import ktfx.layouts.*
108

119
class App : Application() {
10+
1211
override fun start(stage: Stage) {
12+
val hello = Hello()
13+
hello.sayHello(null) // message: String!
14+
hello.sayHelloNullable("hello") // message: String?
15+
hello.sayHelloNonNull("message") // message: String
1316
stage.scene {
1417
gridPane {
1518
hgap = 10.0
@@ -25,6 +28,7 @@ class App : Application() {
2528
stage.show()
2629
}
2730
}
31+
2832
companion object {
2933
@JvmStatic
3034
fun main(vararg args: String) = launchApplication<App>(*args)

0 commit comments

Comments
 (0)