2023-10-01から1ヶ月間の記事一覧

sortedWith

data class CustomDate( val year: Int, val month: Int, val day: Int ) fun main() { var custumDates = listOf( CustomDate(2023, 1, 1), CustomDate(2023, 1, 2), CustomDate(2023, 2, 1), CustomDate(2022, 1, 1), CustomDate(2022, 1, 2), CustomDate(…

SwiftUI新しいdismiss書き方

以前の書き方: 定義: @Environment(\.presentationMode) private var presentationMode 使用: presentationMode.wrappedValue.dismiss() 現在の書き方: 定義: @Environment(\.dismiss) private var dismiss 使用: dismiss()

compareValuesByを使ってもっと簡単にComparableを実装する

data class CustomDate( val year: Int, val month: Int, val day: Int ) : Comparable<CustomDate> { override fun compareTo(other: CustomDate): Int { return compareValuesBy(this, other, CustomDate::year, CustomDate::month, CustomDate::day) } override fun t</customdate>…

Comparableを実装する

data class CustomDate( val year: Int, val month: Int, val day: Int ) : Comparable<CustomDate> { override fun compareTo(other: CustomDate): Int { if (year == other.year) { if (month == other.month) { return day - other.day } else { return month - other</customdate>…