Category "methods"

Can we actually do rspec testing on ruby if my methods don't have parameters?

I have a method but doesn't have a parameter, for example def goodbye puts "" puts "Thank you, #{name} for using our service." puts "Good luck with

Calling a native C++ method from C++/CLI

I'm developing Wordle in C++ using a .net graphic interface with visual studio. I have a file.h that contains a class "WordDatabase", and I need to use one of t

Method parameter auto completion for a class instance

I am trying to get auto completion of method parameter names for class instances but can't quite figure it out. Take this example class: class Abc: def meth

Vue JS: reactive syntax

While I was trying to grasp reactivity fundamentals and its syntax I've encountered following problem. Consider this snippet: const app = Vue.createApp({ dat

Call a Java method using MySQL triggers

I'm writing an application that retrieves data from a table in a MySQL database and displays it in a JTable. Whenever an insert/update/delete operation is made

Does the .includes method in JavaScript loop through the array and case O(n)?

Does the .includes method cause O(n^2) when run with another loop such as in this simple example? function myFn(){ let age = people.map(person => {

How do I capture inputs from a system.out.println to compare if they match? [duplicate]

I am a first year studying app development and I have a login and registration assignment. But Im struggling to make a method where it checks

How to remember if a method mutates the original array?

I know I can find a list of mutator methods on MDN, still, in practice I always forget if methods like push() or reverse() mutates the original array or creates

How can I program a while loop that waits for my input in Android?

My question is simple. What method can I use to tell my program that a button is pressed? I'm trying some codelines but its not really working (I tryed with isP

Any difference between str.capitalize() and str.title()?

Is there any difference in str.title() vs str.capitalize()? My understanding from the docs is that both methods capitalize the first letter of a word and make t

Javascript forEach Method

Am getting undefined error. var fruits = ["apple", "orange", "cherry"]; document.getElementById("demo").innerHTML = fruits.forEach(myFunction); function myFun

Cannot execute method in an NSPanel from a separate NSWindow in Objective-C

I have a MacOS Objective-C project with a parent NSWindow and an NSPanel containing a TableView whose delegate and data source is a class called TableController

I need to decrease a value of the property only from specific class objects

I have three classes and two of them inheriting from an Animal class, Carnivore class should have method to decrease health by 50 if I call the method on Herbiv

C# map a list of abstract class objects to derived class for method overloading

I am in a situation where I am iterating a List<Animal> and want a Handler class to handle each element according to its derived type. The way I'm doing i

Pointer receiver method compilation problem: Cannot call a pointer method on 'MyObj{}'

I have the following method defined: func (o *MyObj) parse(something string) string { // Do stuff } This code (1) compiles just fine: (&MyObj{}).parse(

Class is public, should be declared in a file named .java

I'm having this problem which I'm not sure why it's caused. "class Account is public, should be declared in a file named Account.java" I have 5 classes in my

Communication between BroadcastReceiver and Activity - android

I have a broadcast receiver in my app which is fired every time the user gets an incoming call. Now, when it happens, I need the broadcast receiver to invoke a

Safe method to get value of nested dictionary

I have a nested dictionary. Is there only one way to get values out safely? try: example_dict['key1']['key2'] except KeyError: pass Or maybe python h

Why does passing and changing a class self-variable with an external function work for manipulating iterables but not variables?

I ran into a very hard to track down bug in my program where a class self-iterable was manipulated by an external function and discovered that some self-variabl

Having trouble creating overloaded constructor, instantiating an object

I'm new with Java and I'm having trouble going along with my teacher's video lectures (I'm taking an online class), and I'm having trouble with this assignment: