This file contains 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
class ExampleShark { | |
var name:NSString! | |
var howSwim:NSString! | |
init(name:NSString!, howSwim:NSString!) { | |
self.name = name | |
self.howSwim = howSwim; | |
} | |
func swim() -> String { |
This file contains 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
import Foundation | |
class GrayShark { | |
var name:String | |
var howSwim:String | |
init(name:String, howSwim:String) { | |
self.name = name | |
self.howSwim = howSwim; | |
} |
This file contains 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
import Foundation | |
class GrayShark { | |
var name:String | |
var howSwim:String | |
init(name:String, howSwim:String) { | |
self.name = name | |
self.howSwim = howSwim; | |
} |
This file contains 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
class NonObjCShark { | |
var name:NSString! | |
var howSwim:NSString! | |
init(name:NSString!, howSwim:NSString?) { | |
self.name = name | |
self.howSwim = howSwim; | |
} | |
func swim() -> String { |
This file contains 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
public enum Suit { | |
Spades, Hearts, Diamonds, Clubs; | |
} | |
for (Suit suit : Suit.values()) { | |
System.out.println(suit.toString()); | |
} |
This file contains 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 Rank:Int { | |
case Ace = 1 | |
case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten | |
case Jack, Queen, King | |
// Here's an undocumented trick: How to enumerate enums using Generator! | |
// I wish I could use yield though ;( | |
class EnumGenerator:Generator { | |
var i = 1 | |
func next() -> Rank? { |
This file contains 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
class MyClass { | |
var someValue:Int | |
func someMethod() -> Int { | |
return 42 | |
} | |
var callback:(Int) -> (Void) = {(value:Int) -> (Void) in | |
// Using self within a closure owned by self makes reference loop | |
self.someValue = self.someMethod() + value | |
} |
This file contains 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
import Foundation | |
var l = [ | |
"abesi", | |
"hidebu", | |
"tawaba", | |
] | |
var m = [ | |
"abesi": 1, |
This file contains 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
Initialize engine version: 4.3.3f1 (c8ca9b6b9936) | |
GfxDevice: creating device client; threaded=1 | |
OpenGL: | |
Version: OpenGL 2.1 [2.1 NVIDIA-8.24.9 310.40.25f01] | |
Renderer: NVIDIA GeForce GTX 680MX OpenGL Engine | |
Vendor: NVIDIA Corporation | |
VRAM: 2048 MB | |
Extensions: GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_c |
This file contains 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
public int getCryptoTypeDumb() { | |
// With Plain Java | |
List<Network> networkList = new ArrayList(mNetworkSet); | |
Collections.sort(networkList, NetworkComparators.CRYPTOTYPE_WEAKEST_TO_STRONGEST); | |
return networkList.get(0).getCryptoType(); | |
} | |
public int getCryptoType() { | |
// With Google Guava | |
return Ordering.from(NetworkComparators.CRYPTOTYPE_WEAKEST_TO_STRONGEST).min(mNetworkSet).getCryptoType(); |