This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Double { | |
static var min : Double { | |
get { | |
return -2147483648 | |
} | |
} | |
static var max : Double { | |
get { | |
return 2147483647 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
subscript(index : Int) -> Character{ | |
get { | |
return self[advance(self.startIndex, index)] | |
} set(newValue) { | |
self = self.stringByReplacingCharactersInRange(Range<String.Index>(start: advance(startIndex, index), end: advance(startIndex, index+1)), withString: String(newValue)) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addPrefix(c : Character) -> (String) -> String { | |
return { | |
(currentString : String) -> String in | |
let result = String(c) + currentString | |
return result | |
} | |
} | |
//OR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func recursiveFibonacci(number : Int) -> Int { | |
return number <= 1 ? 1 : recursiveFibonacci(number - 2) + recursiveFibonacci(number - 1) | |
} | |
var fibonacci : Int -> Int = recursiveFibonacci | |
fibonacci(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let word = "detartrated" | |
func palindromeWord(word : String) ->Bool { | |
return String(reverse(word)) == word ? true : false | |
} | |
palindromeWord(word) // OUTPUT -> True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 1...100 { | |
switch (i) { | |
case let x where x%15 == 0: | |
println("CracklePop") | |
case let x where x%3 == 0: | |
println("Crackle") | |
case let x where x%5 == 0: | |
println("Pop") | |
default: | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in 1...10{ | |
switch (i) { | |
case let x where x%2 == 0: | |
println("even") | |
case let x where x%2 != 0: | |
println("odd") | |
default: | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Enum | |
enum Country { | |
case Spain, France | |
} | |
//Classes | |
class Spain : Language { | |
func code() -> String { | |
return "SP" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//REQUIRE PARSE | |
var Parse = require('parse').Parse; | |
//ADD NECESSARY KEYS - FOR MODIFY IS NECESSARY MASTER KEY | |
Parse.initialize(APP_KEY, JSC_KEY, MASTER_KEY); | |
//YOU HAVE USE THIS COMMAND FOR USE MASTER KEY | |
Parse.Cloud.useMasterKey(); | |
var UserClass = Parse.Object.extend('_User'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For use Gson, you need a Gson jar. Download from this https://code.google.com/p/google-gson/ | |
class Student { | |
private String name; | |
private int mark; | |
private String city; | |
public Student(String name, int mark, String city) { | |
this.name = name; | |
this.mark = mark; | |
this.city = city; |