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

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

Assignment of objects in VB6

Like many modern languages, VB6 has value types and reference types. Classes define reference types. On the other hand, your basic types like Integer are value types. The basic difference is in assignment: Dim a as Integer Dim b as Integer a = 2 b = a a = 1 The result is that a … Read more

What exactly is a Class Factory?

Here’s some supplemental information that may help better understand several of the other shorter, although technically correct, answers. In the strictest sense a Class Factory is a function or method that creates or selects a class and returns it, based on some condition determined from input parameters or global context. This is required when the … Read more