zoukankan      html  css  js  c++  java
  • swift,

    http://gashero.iteye.com/blog/2075324

    // Playground - noun: a place where people can play

     

    //haha 没有分好,编译器推断类型,好玩,空格严格限制

    import UIKit

     

     

    var str = "Hello, playground"

    println(str)

     

     

    let label = "the width is"

    let width = 94

    let widthLabel = label + String(width)

     

    var shoppingList = ["catfish","water"]

    shoppingList[0]

    var occupation = ["a":"bb"]

    occupation["a"]

    println(occupation)

     

    let scores = [12,34,50]

    for a in scores {

        println(a)

        if a==12 {

            println("hello world")

        }

    }

     

    let interestingNumbers = [

    "Prime":[2,3,4],

        "fibo":[1,5]

    ]

     

    //字典可以这样遍历

    for (kind,numbers) in interestingNumbers{

        println(kind)

    }

     

    //->这符合太迷惑人了

    func greet(name:String,day:String)->String{

        return "hello world (name),today is (day)"

    }

     

    greet("bob", "tuesday")

     

    func getPrices() ->(Double,Double,Double){

        return (2.3,1,1)

    }

    getPrices()

    //...代表可变的参数,这里面也有元组,哈哈,闭包的概念,就是传递函数指针,

     

    class Shape{

        var number = 0

        func myFunc()->String{

            return "a shape with (number) sides"

        }

    }

     

    var shape = Shape()

    shape.number = 10

    shape.myFunc()

     

    //当一个语言讲了 义变量常量,函数定义,类定义,对象,调用,数组字典,就等于讲完了,

     

  • 相关阅读:
    CF1202F You Are Given Some Letters...
    CF1178E Archaeology
    PTA (Advanced Level) 1005 Spell It Right
    PTA (Advanced Level) 1004 Counting Leaves
    Qt5——从零开始的Hello World教程(Qt Creator)
    PTA (Advanced Level) 1003 Emergency
    PTA (Advanced Level) 1002 A+B for Polynomials
    HDU 1272 小希的迷宫
    FZU 2150 Fire Game
    HihoCoder
  • 原文地址:https://www.cnblogs.com/guligei/p/4429076.html
Copyright © 2011-2022 走看看