Jasin Colegrove
01/07/2022, 7:02 PMval pdfDoc = PdfDocument(PdfWriter(fileName))
but the implementation for PdfDocument is
public PdfDocument(PdfWriter writer) {
this(writer, new DocumentProperties());
}
what is pdfDoc assigned to with no return value?Kirill Grouchnikov
01/07/2022, 7:03 PMRodrigo Bressan De Souza
01/07/2022, 7:04 PMKirill Grouchnikov
01/07/2022, 7:04 PMAyfri
01/07/2022, 7:18 PMkqr
01/07/2022, 8:04 PMRob Elliot
01/07/2022, 8:15 PMpublic class PdfDocument {
public PdfDocument(PdfWriter writer, DocumentProperties documentProperties) {
}
public PdfDocument(PdfWriter writer) {
this(writer, new DocumentProperties());
}
}
The equivalent Kotlin would be:
class PdfDocument(
writer: PdfWriter,
properties: DocumentProperties = DocumentProperties(),
)
Or if you wanted it to be the basically the same byte code:
class PdfDocument(
writer: PdfWriter,
properties: DocumentProperties,
) {
constructor(writer: PdfWriter): this(writer, DocumentProperties())
}
Kirill Grouchnikov
01/07/2022, 8:23 PMpublic PdfDocument(PdfWriter writer)
doesn't seem to return anything - and that is true in the Kotlin world. But in the Java world that's the constructor syntax, so the "return" of that is a PdfDocument
objectAyfri
01/07/2022, 8:44 PMephemient
01/07/2022, 8:45 PMAyfri
01/07/2022, 8:47 PMephemient
01/07/2022, 8:47 PM@JvmOverloads
Kotlin generates a constructor taking every parameter, a bitmask of which parameters are present (or several, depending on how many arguments there are), and a DefaultConstructorMarker (for overload disambiguation)Ayfri
01/07/2022, 8:48 PMephemient
01/07/2022, 8:48 PMAyfri
01/07/2022, 8:48 PMephemient
01/07/2022, 8:49 PM