Skip to main content
0 votes
1 answer
39 views

Is it possible to change the return type of a method based on what is passed in as a parameter? [duplicate]

Is it possible for the same method have different return types based on what is passed in, so that for example GetScripts(new Camera()) returns a Camera and GetScripts(new Cube()) returns a Cube? I ...
Waarnov's user avatar
  • 25
0 votes
1 answer
28 views

Coq Error Syntax error: '.' expected after [gallina] (in [vernac_aux])

So I have this code: Require Import Unicode.Utf8. Require Import String. Inductive AExp := | avar : string → AExp | anum : nat → AExp | aplus : AExp → AExp → AExp | amul : AExp → AExp → AExp. ...
Vlad's user avatar
  • 3
0 votes
0 answers
27 views

My Angular HTML Page doesn't load after populating ng2-chart datasets' data

I'm currently working on an Angular project to develop a dashboard of sorts. public donutChartData: any = { labels: [], datasets: [ { data: [1, 1, 1], backgroundColor: [ ...
Pablo's user avatar
  • 1
1 vote
1 answer
32 views

Why do scikit-learn predict(X) methods accept a 2D matrix rather than a 1D vector?

Does anyone know why the predict(X) methods of scikit-learn classifiers and regressors expect input X to be a 2D array (matrix) rather than a 1D array (vector)? I'm just curious about the history of ...
JMcCaffrey's user avatar
0 votes
0 answers
70 views

Is there a way to slow down the code execution of a method? [closed]

I am trying to make a method related to the movements of the ghosts in a PacMan game. However, I would like to find a way to delay the ghost movements by 1 tick (250 ms) everytime before I call the ...
Tony Lin's user avatar
1 vote
1 answer
26 views

Directly calling a method in JS works, but not with .call or .apply

I have a node resulting from a call let node = document.getElementById('myID'); node is a Node, which has a classList object that has a remove() method This works for me: node.classList.remove('alert'...
Cosoiu Constantin's user avatar
2 votes
2 answers
72 views

How can I define a vararg with three types in Java?

Since I need a Java method to receive any number of objects of three specific classes I decided to use a vararg ... to implement it. However, I have the restriction that these three classes are: java....
Joe DiNottra's user avatar
-2 votes
0 answers
41 views

Can i manipulate variable of class using its method [duplicate]

class example(): id = 1 def __init__(self, name): self.name = name def incr(self): my_id = id id += 1 def info(self): print(self.name) (global id) isn't working I want ...
Mudasir Ahmed's user avatar
-1 votes
0 answers
30 views

Why does “this” change when calling an object method as a standalone function? [duplicate]

I’m learning JavaScript and have a question about the this keyword when dealing with object methods. Specifically, I’m seeing a different behavior when I assign an object method to a variable and call ...
Han's user avatar
  • 11
0 votes
0 answers
53 views

Search results undefined while loading from controller on Rails view

I am trying to do search functionality for my Rails MVC learning. I am adding title , description and category name as filter columns. And checking each parameter id defined in my model class using ...
Mr.DevEng's user avatar
  • 2,815
0 votes
0 answers
20 views

Javascript - How to recursively call a method as a callback? [duplicate]

As a learning exercise, I'm making a Javascript browser game where when the user presses a button, it simulates rolling several 6-sided dice and then shows images that correspond to the random value ...
Always a Newb at Something's user avatar
-1 votes
1 answer
88 views

I need help formatting this code as a Ruby method [closed]

So, I have passing code for what I am trying to achieve. Now I need to format it in a method format that takes two parameters. I have more experience with JavaScript functions at this point and am ...
Jessica Yeverino's user avatar
3 votes
1 answer
36 views

How can I dynamically add methods to a Python class at runtime while preserving their type annotations?

from typing import Callable class MyClass: pass def dynamic_method(self, x: int, y: str) -> str: return f"{x} - {y}" setattr(MyClass, 'dynamic_method', dynamic_method) ...
Visva Dheeran Balasubramaniam's user avatar
-1 votes
1 answer
36 views

Unable to pass self.instance_variable as default into a class method

I have a class and method that I am trying to pass a self.instance_variable as default but am unable to. Let me illustrate: from openai import OpenAI class Example_class: def __init__(self) -> ...
Legion's user avatar
  • 474
-2 votes
1 answer
46 views

Is dunder an official designation for `__method__` in Python?

In a Python class you can use methods whose name is preceded and followed by a double underscore, which are called by a "special" syntax which is not the usual object.method() syntax. For ...
robertspierre's user avatar

15 30 50 per page
1
2 3 4 5
2033