首页 > 编程语言 > 详细

Day11 swift2.0-String

时间:2016-04-19 00:06:00      阅读:189      评论:0      收藏:0      [点我收藏+]

//                                      **Day 11

//                                      **swift 2.0  String

 

var arr = [1,"2",3.3]

print("\(arr)")

 

var dict = ["a":1,"b":2,"c":3]

(dict as NSDictionary).allKeys

(dict as NSDictionary).allValues

 

var string = "hello world!"

let range = string.startIndex..<string.startIndex.advancedBy(5)

 

string.replaceRange(range, with: "Hi")

 

string

 

print("\(string)")

 

let range2 = string.endIndex.advancedBy(-6)..<string.endIndex

 

string.substringWithRange(range2)

 

 

var animals = "\u{1F60E}hoho~"

animals.characters.count

 

var swift_string = "symbol2.0"

let string2 = swift_string + "ahaha~"

print("\(string2)")

 

swift_string

 

swift_string.appendContentsOf("addString")

 

print("\(swift_string)")

 

var i = 1

for  ; i <= 100 ;  {

    i*i

    i += 1

}

 

for var a = -6.28 ; a <= 6.28 ; a += 0.2 {

    sin(a)

    

    cos(a)

    

    tan(a)

    

    1/tan(a)

}

 

var newstring = "hello world!"

for var c in newstring.characters {

    print("\(c)")

    

    if c == "r" {

        c = " "

        print("\(newstring.endIndex)")

    }

    print("\(c)")

}

 

print("\(newstring)")

Day11 swift2.0-String

原文:http://www.cnblogs.com/tony0571/p/5406207.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!