casting Questions
4
Solved
I have a table with an enum type in it, and I created a function to add data to that table. I want that function to be generous in what to accept, so I take a text as the enum type and want to cast...
Evergreen asked 5/9, 2013 at 8:52
10
Solved
Well, I have a class Customer (no base class).
I need to cast from LinkedList to List. Is there any clean way to do this?
Just so you know, I need to cast it to List. No other type will do. (I'm ...
1
Solved
Is there any difference between the typing.cast function and the built-in cast function?
x = 123
y = str(x)
from typing import cast
x = 123
y = cast(str, x)
I expected that mypy might not like th...
8
Solved
Which is the the best way (if there is one) to cast from number to string in Typescript?
var page_number:number = 3;
window.location.hash = page_number;
In this case the compiler throws the err...
Barmaid asked 13/9, 2015 at 21:15
4
Solved
I am trying to follow this tutorial creating a DropDown. But I can not copy his code because Flutter 2.0 is forbidding it because of these lines:
void findDropdownData() {
RenderBox renderBox = a...
Nkvd asked 11/4, 2021 at 13:18
1
There are some things that I do not understand about reinterpret_cast.
The following snippet from cppreference has this to say about casting between integral values and pointers.
A value of any i...
3
Solved
Is there any difference between what the TypeScript spec calls a type assertion:
var circle = <Circle> createShape("circle");
And the newer as operator:
var circle = createShape("circle")...
Tapestry asked 3/11, 2015 at 15:35
12
Solved
I'd like to enumerate a string and instead of it returning chars I'd like to have the iterative variable be of type string. This probably isn't possible to have the iterative type be a string so wh...
6
Solved
I have a value in row that equals -16777056, but how do I cast it to Color?
Something like that:
Color = (Color) Convert.ToInt32(((DataRowView)this.dataGridView1.Rows[e.RowIndex].DataBoundItem)["...
7
Solved
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?
Prater asked 3/12, 2015 at 22:28
3
Solved
I am learning Kotlin. My code is as follows:
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
decoupler.attachNotifier(this)
...
2
Solved
As you can see in below code, the TS compiler infers the type as :
const message = Math.random() > 0.5 ? "hello, can you here me" : null;
So message variable is inferred as "hell...
Yoicks asked 22/11, 2022 at 6:50
8
Solved
Map session = ActionContext.getContext().getSession();
session.put("user", user);
This code generates a warning: Type safety: The method put(Object, Object) belongs to the raw type Map. Reference...
2
The following code causes CS0266 in Visual Studio:
double x = 1.23;
int y = x;
But the following code compiles in Visual Studio, and causes an implicit cast double to int:
double x = 0;
ReadOnlyCo...
Dissuade asked 18/11, 2022 at 13:9
5
I'm having issues using the instanceof operator and it doesn't seem to work. Here is a part of my code:
const results = _.map(items, function(item: Goal|Note|Task, index: number) {
let result =...
Quadric asked 30/8, 2017 at 15:10
2
Solved
I had a matrix saved as a numpy type, call it "X_before" (for example, its shape is 100*30).
Since I want to feed it to an AutoEncoder using Pytorch library, I converted it to torch.tenso...
Ullrich asked 18/2, 2021 at 12:49
6
Solved
Please consider the following snippet:
public interface MyInterface {
public int getId();
}
public class MyPojo implements MyInterface {
private int id;
public MyPojo(int id) {
this.id = i...
6
Solved
I want to do something like this:
List<Child> childList = new List<Child>();
...
List<Parent> parentList = childList;
However, because parentList is a List of Child's ancestor,...
Parentage asked 22/11, 2009 at 4:22
10
Solved
public interface IDic
{
int Id { get; set; }
string Name { get; set; }
}
public class Client : IDic
{
}
How can I cast List<Client> to List<IDic>?
20
Solved
For example, lets say you have two classes:
public class TestA {}
public class TestB extends TestA{}
I have a method that returns a List<TestA> and I would like to cast all the objects in ...
Wear asked 1/6, 2009 at 3:25
6
Solved
Map<String,Integer> m;
m = new TreeMap<String,Integer>();
Is it good practice to add the following cast just to avoid the null pointer exception when m.get() is null.
System.out.prin...
Lashandralashar asked 8/10, 2014 at 13:57
14
Solved
I have a script which reads a text file, pulls decimal numbers out of it as strings and places them into a list.
So I have this list:
my_list = ['0.49', '0.54', '0.54', '0.55', '0.55', '0.54'...
15
Solved
I want to convert a Float to an Int in Swift. Basic casting like this does not work because these types are not primitives, unlike floats and ints in Objective-C
var float: Float = 2.2
var integer...
Edelweiss asked 4/6, 2014 at 5:46
6
Solved
I've got an application that stores some data in DynamoDB using Jackson to marshall my complex object into a JSON.
For example the object I'm marshalling might look like this:
private String aSt...
Barbusse asked 15/3, 2013 at 11:3
4
Solved
In Go, if you define a new type e.g.:
type MyInt int
You can't then pass a MyInt to a function expecting an int, or vice versa:
func test(i MyInt) {
//do something with i
}
func main() {
anI...
© 2022 - 2024 — McMap. All rights reserved.