Duplicating declarations in a swift playgground -


is there way introduce concept of 'scope' while trying things out in playground?

say want test couple of implementations of class myclass declare it, write code test things. decide want compare version of class myclass implementation.

redeclaring myclass give redeclaration error.

so can have playground treat first declaration of myclass , associated code separately second without changing class name or creating multiple playgrounds?

thanks

it's bit of hack, can use nested types – declare struct purpose of have kind of scoping:

struct scope1 {     class myclass { } }  struct scope2 {     class myclass { } }  let x = scope1.myclass() let y = scope2.myclass()  // if want switch between using  // 1 vs other typealias myclass = scope1.myclass let z = myclass() 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -