What's the difference between the ruby irb prompt modes?

后端 未结 2 782
无人共我
无人共我 2021-01-06 09:19

I can change the irb prompt mode with

irb --prompt prompt-mode

I can see what null and simple does, but I can\'t

2条回答
  •  渐次进展
    2021-01-06 09:28

    The answer to those questions lie in IRB.conf[:PROMPT] which is a hash whose keys are the different prompts and whose values are the configurations for each prompt. Read this to a understand a prompt's configuration.

    The difference between null and xmp is that xmp displays a result indented with an arrow:

    $ irb --prompt xmp -f
    2**10
        ==>1024
    

    while null doesn't indent or display the arrow:

    $ irb --prompt null -f
    2**10
    1024
    

    You should be able to answer your second question once you read the above link and understand that prompts have different modes and different configurations for them.

提交回复
热议问题