当前位置:网站首页>Scala sample object
Scala sample object
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
// Sample object
// stay Scala in , use case Decorated singleton objects are called sample objects , And it has no main constructor
// It is mainly used in two places
//1. Use as enum value
//2. As a message passing without any parameters
object Sample object {
trait Sex
case object Male extends Sex
case object Female extends Sex
case class Person(var name: String, var sex: Sex) {
}
def main(args: Array[String]): Unit = {
val p = Person(" Zhang San ", Male)
println(p)
}
}
边栏推荐
- Mobile security tool apktool
- QT (36) -rapidjson parsing nested JSON
- The problem of multiple callback of video ads stimulated by applets (offcolse problem)
- Use of navigation and navigationui
- Add information on the left and add parts on the right of the status bar
- [micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
- 百公里加速仅5.92秒,威兰达高性能版以高能产品实力领跑
- What is test development? Can you find a job at this stage?
- The basic principle and application of iterator and enhanced for
- If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
猜你喜欢

Xcode预览(Preview)显示List视图内容的一个Bug及解决

Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022

I 刷题 I — 复制带随机指针的链表

Use and click of multitypeadapter in recycleview

The basic principle and application of iterator and enhanced for

51 single chip microcomputer multi computer communication

Sliding window technology based on byte in transport layer

Use of JMeter easynmon

Use of navigation and navigationui

百公里加速仅5.92秒,威兰达高性能版以高能产品实力领跑
随机推荐
2022年全国最新消防设施操作员(高级消防设施操作员)模拟题及答案
Usage of assert
Sliding window technology based on byte in transport layer
【Redis实现秒杀业务④】一人一单,不可重复购买
JS dynamically generates variable names and assigns values
Use coordinatorlayout+appbarlayout+collapsingtoolbarlayout to create a collapsed status bar
Go crawler framework -colly actual combat (II) -- Douban top250 crawling
Source code analysis the problem that fragments cannot be displayed in the custom ViewGroup
智能合约安全审计入门篇 —— delegatecall (2)
Basic summary of MySQL database knowledge
If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
adb shell getevent
C# 闭包的垃圾回收
我想问一下兴业证券怎么开户?通过链接办理股票开户安全吗
[redis realizes seckill service ④] one order for one person, and cannot be purchased repeatedly
QT (35) - operate excel qxlsx qaxobject
Virtual machine - network configuration
2021-09-12
Can communication experiment between C and C
Qiniu cloud uploads video to get the first frame of video