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 
  • 相关阅读:
    域账户-配置文件
    创建任务计划
    查看系统和PowerShell版本
    查找数组中元素的索引位置
    更改计算机名称,修改密码
    生成GUID
    微服务架构 vs. SOA架构
    springMvc架构简介
    Spring Boot和Spring cloud
    Spring链接汇总
  • 原文地址:https://www.cnblogs.com/ufindme/p/3950009.html
Copyright © 2011-2022 走看看