Category "casting"

How to conditionally cast a type in dart?

It seems if it's just a variable, I can conditionally cast like this. Animal animal = Dog(); if (animal is Dog) { animal.bark(); // animal is of type Dog her

What is difference between "as" and "is" operator in Kotlin?

In Java, I can write code like: void cast(A a) { if(a instanceof Person) { Person p = (Person) a; } } In Kotlin, what should I do? Us

Fastest way to cast a float to an int in javascript?

Let's say I have x = 12.345. In javascript, what function floatToInt(x) has the fastest running time such that floatToInt(12.345) returns 12?

Steps to programmatically cast from android to miracast receiver

I'm trying to write an app that will start casting the screen from an Android phone to a TV via miracast. I'm using an HDMI dongle since the TV in question does

CASE statement in Netezza

I am new to Netezza so may be I am not able to figure out the issue. I have a scenario to implement in informatica with Netezza as the database. As few functio

How to split string in chars and get code of each char in freemarker?

I think that I can split using this: <#list str as c> ... </#list> But then I need to convert this char to byte and add it to another number.

How can I convert a buffer of a slice of bytes (&[u8]) to an integer?

I am reading raw data from a file and I want to convert it to an integer: fn main() { let buf: &[u8] = &[0, 0, 0, 1]; let num = slice_to_i8(buf

How do I idiomatically convert a bool to an Option or Result in Rust?

It seems there is no way of such one-line conversion using std. I do not like this kind of verbosity: match my_bool { true => Ok(()), false => Err

TypeScript enum to object array

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milest

Socket Programming, Casting sockaddr_in to sockaddr. Why?

Here is a sample socket programming snippet from the client side. My question revolves around the type-casting that casted sockaddr_in into sockaddr. My questio

How to cast a datetime format to date as string in SQL Server

I am struggling to find a solution for the below issue. date1 = 31-08-2017 12:10:00 I want to cast it as string and need to take date (31-08-2017) alone. Th

Casting Any to Tuple2

I have a Scala function which passes message of type 'Any'. In most cases it will be a tuple of size 2. The function that receives this message needs to see the

SQL error "ORA-01722: invalid number"

A very easy one for someone, The following insert is giving me the ORA-01722: invalid number why? INSERT INTO CUSTOMER VALUES (1,'MALADY','Claire','27 S

Can casts be completely avoided with a good design?

I'm wondering whether situation exists where casting is completely necessary. I'm talking here about casts between classes, not basic types. Is casting (be it

Assignment in an if statement

I have a class Animal, and its subclass Dog. I often find myself coding the following lines: if (animal is Dog) { Dog dog = animal as Dog; dog.Name