How to specify ranges in YAML?

后端 未结 3 2366
终归单人心
终归单人心 2021-02-20 16:07

I can express

3rd page is the title page

in YAML

title: 3

What about the following?

相关标签:
3条回答
  • 2021-02-20 16:50

    Range is application specific. The following may be meaningful for some applications:

    -1 .. Q

    a .. Щ

    23 .. -23.45

    1 .. 12:01:14 (both are integers in YAML !)

    But the ruby way is also unclear since it does not say whether the end values are included or not: 10 .. 15

    (Are you only talking about ranges of integers ?)

    0 讨论(0)
  • 2021-02-20 16:51

    Andrey is right - there is no such thing as a basic range. Ranges can be defined on top of totally ordered data types. YAML does not even know the concept of ordering so it makes no sense to talk about ranges in YAML. YAML only knows the concept of node types, the concept of equality, and some predefined kinds of links between nodes. By the way I don't know any other data serialization lange (JSON, XML, CSV, Hessian, Protocol Buffers...) that natively supports ranges.

    0 讨论(0)
  • 2021-02-20 16:52

    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 
    ...
    

    Look here

    0 讨论(0)
提交回复
热议问题