Dynamic class in Angular.js

You can simply assign a function as an expression and return proper class from there. Edit: there is also better solution for dynamic classes. Please see note below. Snippet from view: <div ng-class=”appliedClass(myObj)”>…</div> and in the controller: $scope.appliedClass = function(myObj) { if (myObj.someValue === “highPriority”) { return “special-css-class”; } else { return “default-class”; // Or … Read more

Can I use in Google Apps Scripts a defined Class in a library with ES6 (V8)?

As written in the official documentation, Only the following properties in the script are available to library users: enumerable global properties function declarations, variables created outside a function with var, and properties explicitly set on the global object. This would mean every property in the global this object are available to library users. Before ES6, … Read more

Fortran polymorphism in pointers

When you have polymorphism like this there are two things to consider about an object: its dynamic type and its declared type. The parameters component of test_mask (base_mask) is declared as class(base_pars),pointer :: parameters Such a component therefore has declared type base_pars. Come the pointer assignment mask_test%parameters=>par_test mask_test%parameters has dynamic type the same as par_test: … Read more

Copy Groovy class properties

I think the best and clear way is to use InvokerHelper.setProperties method Example: import groovy.transform.ToString import org.codehaus.groovy.runtime.InvokerHelper @ToString class User { String name=”Arturo” String city = ‘Madrid’ Integer age = 27 } @ToString class AdminUser { String name String city Integer age } def user = new User() def adminUser = new AdminUser() println “before: … Read more

Access variable in different class – Swift

I have solved this by creating a generic main class which is accessible to all views. Create an empty swift file, name it ‘global.swift’ and include it in your project: global.swift: class Main { var name:String init(name:String) { self.name = name } } var mainInstance = Main(name:”My Global Class”) You can now access this mainInstance … Read more

Swift and using class extension

For me it seems completely reasonable since you can use extensions to expose different parts of logic to different extensions. This can also be used to make class conformance to protocols more readable, for instance class ViewController: UIViewController { … } extension ViewController: UITableViewDelegate { … } extension ViewController: UITableViewDataSource { … } extension ViewController: … Read more

Class constructor type in typescript?

Edit: This question was answered in 2016 and is kind of outdated. Look at @Nenad up-to-date answer below. Solution from typescript interfaces reference: interface ClockConstructor { new (hour: number, minute: number): ClockInterface; } interface ClockInterface { tick(); } function createClock(ctor: ClockConstructor, hour: number, minute: number): ClockInterface { return new ctor(hour, minute); } class DigitalClock implements … Read more