scala - 如何在scala中实现自定义键映射?
问题描述
我得到了以下内容Map
,scala
并想在Map
. 由于某种原因,它返回给定的错误。我可能必须为case objects
? 如何Map
使用自定义键对象实现 a?
sealed trait Status
case object Open extends Status
case object Processing extends Status
case object Completed extends Status
val map = Map(
Open -> "open",
Processing -> "processing",
Meeting -> "meeting",
MissingInformation -> "missing_information",
Completed -> "completed"
)
map(Open)
type mismatch;
found : o.type (with underlying type example.Status)
required: Product with Serializable with example.Status
解决方案
推荐阅读
- batch-file - 因为可以在 for 循环中使用(双倍 for /F %%L for /F %Skip% 而不使用 /F skipe=%% L 的变量?
- python - 在 Pandas 中计算每个 id 列中连续重复的值
- c# - 从 c# 转换为 vb.net 字节
- c - 为什么我会收到“分段错误(核心转储)”?
- android - 如何将传感器数据采样率延迟到一秒?
- arduino - 如何通过仅连接到一个中断引脚的中断服务程序检测三个开关的按下
- html - ul 媒体查询中断
- angular - 带有 Sort 的 MatTable 似乎没有对列进行排序
- data-warehouse - 维度建模 - 使用角色扮演维度进行钻取
- laravel - 将base64字符串转换为图像并使用laravel发送电子邮件