如何在 YAML 中指定范围? [英] How to specify ranges in YAML?

查看:48
本文介绍了如何在 YAML 中指定范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以表达

第三页是首页

在 YAML 中

title: 3

接下来呢?

第 10 到 15 页包含第 1 章

Pages 10 to 15 contains chapter 1

一种方法是

chapter 1: [10, 11, 12, 13, 14, 15]

我更喜欢这里的范围.YAML 中有类似的东西吗?

I would prefer a range here. Is there anything like that in YAML?

chapter 1: (10..15)

** 更新 **

如果 YAML 中没有范围之类的东西,以下将是我的选择

The following would be my alternative if there is no such thing as range in YAML

chapter 1:
   start page: 10
   end page: 15

推荐答案

在 YAML 中没有直接指定范围的方法,但是一些 YAML 可以存储序列化的对象,例如在 Ruby 中:

There is not direct way to specify ranges in YAML, but some YAML can store serialized objects, for example in Ruby:

...
normal range: !ruby/range 10..20 
exclusive range: !ruby/range 11...20 
negative range: !ruby/range -1..-5 
...

看这里

这篇关于如何在 YAML 中指定范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆