zoukankan      html  css  js  c++  java
  • LRTHW笔记七

    puts "Mary had a little lamb. "
    puts "It's fleese was white as #{'snow'}."
    puts "And everywhere that Mary went."
    puts "." * 10 # what'd that do?
    
    end1 = "C"
    end2 = "h"
    end3 = "e"
    end4 = "e"
    end5 = "s"
    end6 = "e"
    end7 = "B"
    end8 = "u"
    end9 = "r"
    end10 = "g"
    end11 = "e"
    end12 = "r"
    
    # watch that print VS. puts on this line what's it do?
    print end1 + end2 + end3 + end4 + end5 + end6
    puts end7 + end8 + end9 + end10 + end11 + end12

    结果:

    Mary had a little lamb. 
    It's fleese was white as snow.
    And everywhere that Mary went.
    ..........
    CheeseBurger

    注意:

    print和puts中一样,对于字符串变量,他们都是通过“+”将变量连接从而形成一个长的字符串;

    print 一般输出结果后面不换行,而puts输出字串后会换行;

    注意省略号的生成,由此可猜想,如果这样的结果是什么:

      代码:

    puts "01101 " * 8

      输出:

    [ufindme@ufindme rubywork]$ ruby ex7-2.rb 
    01101 01101 01101 01101 01101 01101 01101 01101 
  • 相关阅读:
    ubuntu18.04 常用命令
    docker常用命令
    git
    y7000 intel nvidia 双显卡安装Ubuntu16.04
    linux中fork() 函数详解
    理解GBN协议
    C++ sort
    最近点对-分治
    方便查看 linux/kernel/system_call.s
    方便查看 linux/kernel/asm.s
  • 原文地址:https://www.cnblogs.com/ufindme/p/3950009.html
Copyright © 2011-2022 走看看