Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Chanllenge_Questions.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//: Playground - noun: a place where people can play

import Cocoa

var str = "Hello, playground"
func swapVariables(inout s1:String,inout _ s2:String){
let s3:String=s1
s1=s2
s2=s3
}
var changedString1 = "My name is David"
var changedString2 = "My last name is Xu"
swapVariables(&changedString1, &changedString2)
print(changedString1)
print(changedString2)

func addMultipleString(words:String...)->String{
var newString:String = ""
for word in words{
newString+=word
}
if words.count==0{return "none"}
else {return newString}
}
print (addMultipleString("my ","name ","is ","David."))
print (addMultipleString())


func swap<T>(inout a:T, inout with b:T) { (a, b) = (b, a) } //demo code
var a = "Marin", b = "Todorov"
swap(&a, &b)
[a, b]

func countFrom(from:Int,_ to:Int){
print(from,terminator:"")
if from<to{
countFrom(from+1,to)
}
}
countFrom(1,5)

func reverseText(a:String) -> String {
var b:String = a
var c:String
c.append(b.endIndex.predecessor())

}

4 changes: 4 additions & 0 deletions Chanllenge_Questions.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='osx'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.