Go: Interfaces as return values

I have several structs which I fill with data from MongoDB. type Dog struct { Id string Age int } type Invoice struct { Id int Amount float } I was trying to make a function like this: func LookUp(collection string, ids []string) []interface{} { // I

Other ways to declare arrays in TypeScript

My Typescript file will compile with either of these declarations. Are they equivalent? Is there a name for these ways of declaring arrays? interface Foo { bounds: number[][]; bounds2: [[number, number], [number, number]]; } The library into which I'

Detect the type of parameter passed in the class constructor

I want the constructor of a class to be able to pass two types of parameters, then inside the method do some stuff based on the type of the parameter. the types would be double and String[]. the class and its constructor is something similar to: publ

Incompatible types: int and & lt; nulltype & gt;

I am having trouble with the (hashTable[bucket][size] == null). I was wondering how you could check to see that slot is null if null is not of type int. Any ideas/tips? public void add(int n){ int bucket = hashF(n); int p=0; int size = hashTable[0].l

How to tell Scala that a def returns TypeRef [this.type]

I have a set of objects like the following: abstract class RecordType[T <: Record] object RecordType1 extends RecordType[Record1] object RecordType2 extends RecordType[Record2] ... I'd like to use them in the following way, i.e. each RecordX has a de

Scala overloaded higher order functions cause a type error

I have a overloaded method defined as follows: def g(f: () ⇒ Double): Object = null def g(f: Double ⇒ Double): Object = null def g(f: (Double, Double) ⇒ Double): Object = null def h(f: (Double, Double) ⇒ Double): Object = null While h(math.max _) wor

How to use a type as an expression?

I was wondering if exist a trick to use a Type as an expression, for example in this code: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim ControlType = CheckBox ' CheckBox is a type and cannot be used as an expressio

Convert the framed object to typeof (object)

I have the following POCO classes public interface IObject { Guid Uid { get; set; } } public class Boo : IObject { public Guid Uid { get; set; } public String Name { get; set; } } public class Foo : IObject { public Guid Uid { get; set; } public Stri

Convert void ** pointer to equivalent Java type

I'm loading a C DLL from a program written in Java. I want to be able to call one of the methods from the DLL with this declaration : dll_function(const char* foo1, const char* foo2, const char* foo3, void** bar, size_t* bar2); How do I call this met

Ocaml: why these types?

Hi could someone please explain why the types are as outlined below? I understand that they would have to be int because x+y+z but the number of arguments (ie ->) seems arbitrary to me. let f x y z = x+y+z in f 1 2 3 // int let f x y z = x+y+z in f 1

ExpandoObject with a selection clause

I have to populate below class in Linq Query public class Emp { public string name {get; set;} public dynamic Obj { get; set; } public Emp() { Obj = new ExpandoObject(); } } public LoadData() { var emp = (from d in dbContext.Employees select new Emp

Android - transmit data of different types

What I am trying to achieve is as follows - I have a java class which calls a URL (passed to it), which returns JSON, which calls a call back from within the calling activity which processes the data. This allows reusability of the aSyncTask code. In

Creating a generic type instance in Java

This question already has an answer here: Create instance of generic type in Java? 23 answers I have the following Java class public class MyClass <T extends MyInterface> implements RowMapper<MyInterface> I'm implementing the following method:

How can I serialize an interface?

Suppose I have a Serializable class ShapeHolder that owns an object that implements a Serializable Shape interface. I want to make sure the correct concrete shape object is saved (and the correct type is later restored). How can I accomplish this? in

Accepted collection to work with Excel data

I have a bunch of data that I'm pulling into my application which frankly is best represented as an Excel spreadsheet. By this I mean: There are a lot of columns which need 'summing up' There is a reasonable amount of data (basically a sheet of numbe

How to store these values

is there type is there to store the value <string,string,int> if i use Namedlist(Solr),List it can be achieved? if so how to use. Any other way is there? example: <"A",America,code> <"B",London,code> I need this in ja

What is the difference between a class and a data type?

I have heard the following statement: We can say class is a datatype or a datatype is one type of class. Can anyone explain to me what exactly this means?C# is a strongly typed language; therefore every variable and object must have a declared type.

How to use a Command Command .NET object as a non-string object

Ok so it appears in the .NET framework API docs that the CommandArgument property of the CommandEventArg class is of type 'object' suggesting that I might assign to it something other than a string object yet I get an InvalidCastException using the c

How can I verify that a number is floating or whole?

How to find that a number is float or integer? 1.25 --> float 1 --> integer 0 --> integer 0.25 --> float check for a remainder when dividing by 1: function isInt(n) { return n % 1 === 0; } If you don't know that the argument is a number you ne

Is it possible to use a numeric type as an object key?

It seems that when I use a numeric type as a key name in an object, it always gets converted to a string. Is there anyway to actually get it to store as a numeric? The normal typecasting does not seem to work. Example: var userId = 1; console.log( ty

haskell and function type definition. some questions

if i do any isUpper "asBsd", i'll get True. here, the second element to any is a string. but, if i do this: any ("1" `isInfixOf`) ["qas","123","=-0"] the second element to any is a list of strings. how and

Know what type is a certain interface

I am creating a method that accepts a IOBJECT parameter. there is multiple class that implement this interface. I need to figure out which type IOBJECT is. how would i go about doing thatIt's not ideal, but you can use the "is" operator. Throw i

How to convert an object to the type described by Type class?

I have a object: ExampleClass ex = new ExampleClass(); And: Type TargetType I would like to cast ex to type described by TargetType like this: Object o = (TargetType) ex; But when I do this I get: The type or namespace name 't' could not be found So

clean / best type to store latitude and longitude

In a system level programming language like C, C++ or D, what is the best type/encoding for storing latitude and longitude? The options I see are: IEEE-754 FP as degrees or radians degrees or radians stored as a fixed point value in an 32 or 64 bit i