GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
sample-kotlin
/
sample01
Browse code
add builder pattern
master
1 parent
d22b30a
commit
99e6d3637ead95b6c79858e8dc00a1c83c9153cc
yhornisse
authored
on 18 Nov 2020
Patch
Showing
1 changed file
builder.kt
Ignore Space
Show notes
View
builder.kt
0 → 100644
data class Hoge( val id:Int, val name:String) { class HogeBuilder() { var id:Int? = null var name:String? = null fun build() : Hoge = Hoge( id = requireNotNull(id), name = requireNotNull(name) ) } } fun main(args: Array<String>) { var builder = Hoge.HogeBuilder() builder.id = 1 builder.name = "hoge" var e:Hoge = builder.build() println(e.id) println(e.name) }
Show line notes below