s3协议和swift协议_Swift中的CustomStringConvertible协议是什么?

s3协议和swift协议

The CustomStringConvertible protocol becomes important when you need something to be printed out in the console. Remember, the print() function is going to represent the textual form of the object in the console. However, this function has its own limitations and does not always work as you wish.

当您需要在控制台中打印出某些内容时, CustomStringConvertible协议就变得很重要。 请记住, print()函数将代表控制台中对象的文本形式。 但是,此功能有其自身的局限性,并不能始终如您所愿。

Let me clarify with an example. If you want to define a Car class:

让我用一个例子来阐明。 如果要定义Car类:

You can see the print statement did not work properly. CustomStringConvertible may be very useful in this situation, as it has one requi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值