프로그래밍 Archives - Page 2 of 380 - Jacob is studying on programming 
 https : / / youtu . be / o 1 Occux 4 qR 8 
 https : / / youtu . be / o 1 Occux 4 qR 8 . / 
 https : / / youtu . be / E - yXefhLjNU 
 https : / / www . journaldev . com / 18688 / kotlin - enum - class 
 가장 좋 은 설명 
 Enumerations in Kotlin are data types that hold a set of constants . Enums are defined by adding the modifier enum in front of a class as shown below . Yes , in Kotlin , Enums are classes . 
 Here are some important points about enum classes in kotlin . 
 Each enum constant is an object . Enum constants are separated by commas . 
 Each of the enum constants acts as separate instances of the class . 
 Enums are useful in enhancing the readability of your code since it assigns pre - defined names to constants . 
 Unlike classes , an instance of enum classes cannot be created using constructors . 
 Hence , we can assert that enum classes are abstract . 
 Let ’ s see how the enum class is initialized in the main function of our class . 
 println ( Months . January ) / / prints January 
 println ( Months . values ( ) . size ) / / prints 3 
 println ( Months . valueOf ( " March ")) / / prints March 
 println ( Months . valueOf ( " Mar ")) / / throws java . lang . IllegalArgumentException : No enum constant Months . Mar 
 Few inferences from the above code : 
 Let ’ s see how to tackle this scenario . 
 println ( Months . valueOf ( "")) 
 println ( " The string value does not match with any of the enum constants . ") / / this gets printed . 
 enumContains is a function that calls the lambda function any which iterates over the enum constants to check if any of them matches the string and returns a boolean . 
 Every enum constant has properties : name , ordinal to retrieve the name and position of the constant . 
 println ( Months . January . name ) / / prints January 
 println ( Months . March . ordinal ) / / prints 2 
 Enum toString ( ) 
 We can override the toString ( ) function in the enum class as shown below . 
 return super . toString ( ) . toUpperCase ( ) 
 Enums are classes . So besides defining the constants we can define other things as well that can be present in a class . To do so we need to first end the enum part with a semi colon . 
 Note : Month . January invokes the toString ( ) method of the class whereas Month . January . name directly prints the enum constant ’ s name . 
 Enum Initialisation 
 Enum constants can be initialized using primary constructors as shown below . 
 println ( x . shorthand ) / / prints JAN 
 println ( Months . January . shorthand ) / / prints Shorthand changed to J . 
 Months . February . printSomething ( ) / / prints Second month of the year . 
 println ( Months . February . a ) / / prints Hello , Kotlin Enums 
 Each of the enum constants must override 
 It ’ s possible to define another enum class in the current enum class as shown below . 
 println ( Months . Day . Tuesday ) / / prints Tuesday 
 Only an enum class can invoke another one . The inner class Day cannot be invoked from the enum constants . 
 Enums and when 
 when is Kotlin equivalent of switch in Java . We ’ ve covered the workings of it in the Control Flow tutorial . 
 An example showing how when statements are used with enums is given below . 
 Months . January   -> print ( " Matches with Jan ") 
 Months . February -> print ( " Matches with Feb ") / / prints this . 
 Months . March -> print ( " Matches with Mar ") 
 This brings an end to kotlin enum tutorial . 
 https : / / youtu . be / or _ HJ 6 NGLxc 
 kotlin enum basic 설명 
 https : / / youtu . be / jc 9 AZfZs 7 kY 
 https : / / www . baeldung . com / kotlin - enum 
 Working with Enums in Kotlin 
 내 가 정리 한 enum class 
 child class 는 parent constructor 를 그대로 구현 해야 한다 . 
 parent constructor 가 없 으면 child 에 도 constructor 는 없 다 . 
 parent class 안 에 abstract 로 정의 된 func 은 모든 child 가 구현 해야 한다 . 
 parent class 안 에 abstract 로 정의 되 지 않 은 함수 를 child 안 에 새로 만들 수 있 다 . 
 parent class 는 abstract method , abstract property 를 가질 수 있 다 . ( sealed class 도 같 다 ) 
 sealed class 의 경우 parent constructor 가 정의 되 어 있 지 않 더라도 child class 는 constructor 를 가질 수 있 다 . 각 class 정의 사이 에 구분 자 는 없 다 . ( 정의 부분 뒤 에 enum 의 경우 , 가 붙 는데 sealed class 의 경우 는 없 다는 이야기 ) 
 class CLEAN _ PRESS ( var name : String , var price : BigDecimal ) : BasicGarment 2 ( ) 
 class CLEAN _ ONLY ( ) : BasicGarment 2 ( ) 
 return 10 . toBigDecimal ( ) 
 println ( " test func ") 
 override var testVar : String 
 abstract fun calculatePrice ( ) : BigDecimal 
 abstract var testVar : String 
 https : / / www . geeksforgeeks . org / enum - classes - in - kotlin / 
 original source : https : / / medium . com / incwell - innovations / passing - data - in - android - navigation - architecture - component - part - 2 - 5 f 1 ebc 466935 
 navigation 에서 fragment 간 이 동시 data 를 전달 하 는 2 가지 방법 
 1 . Type Unsafe Way 
 app _ nav . xml 
 To use the bundleOf ( ) is the extension method of androidx . For that we need the dependency : 
 Receive data in destination fragment as : 
 2 . Type Safe Way 
 android jetpack room 
 https : / / developer . android . com / training / data - storage / room / accessing - data 
 더 많 은 내용 이 있 는데 web page 참조 
 android binding adapter 
 loadimage 가 연결 고리 가 된다 .