Category "methods"

How do I open ruby file in irb?

I'm currently using AWS cloud 9. I want to run my code but when I use the ruby command to open up my ruby file in irb it sometimes works or it gives me the erro

How to implement new methods into pipeline using H2O?

I'm new to machine learning and H2O tools, and I'd like to know if there is a high-level H2O interface that allows us to implement new methods into a pipeline.

Return Elements in the array that start with a specific letter e.g D

I am having issue with my code below. I am new to ruby. I want to return names that only start with the letter D but it just returns all the names. When I try t

How to create a void method that outputs an integer and have the method divide the data passed to it by 2?

I'm really brand new at this and still learning C#. I've had a hard time trying to look for a good example to the assignment I'm working on. So you can see exac

BubbleDown function(min heap) not working

I have generated a minheap to this file but I think something I have missed but I can't identify what are the things I have missed. I have missed something on

C# array issue due to indexing of int

I am fairly new to this and trying to learn. I am struggling trying to make a loop to find the max value in an array. I am not sure what I am doing wrong. I hav

How can i use reduce or any other array method, to count and sum up specific properties?

I try to learn more about the array methods and also working with objects. I come up with this dummy example that simulate an incoming data. const data = [

Putting brackets when calling methods from laravel model

My route looks like this: Route::get('/tags/post/{id}', function ($id){ $post = Post::find($id); foreach ($post->tags as $tag) { return

in the program below I have to pass 2 parameters as in update method 1st one to check the stored value & second to update the value in Javascript

how can I update a value in the array of objects? class Person{ data = [] // defining an array constructor(fname, lname, gender){ this

The method 'copy' isn't defined for the type 'PickedFile'

After i upgraded Flutter i followed all the steps for migration code and now i get this error, can't use to .Copy. class ImageInput extends StatefulWidget { f

How can I explicitly assign a receiving variable to be an array

ok, so, I was doing this before and its working: let array = []; if (blablabla) array = ["foo","bar"]; else array = ["this", "that"]; FunctionImUsing(array) An

How to create generic method in Go? (method must have no type parameters)

Golang 1.18beta supports generic, I want to add an extension method on a generic slice. e.g. a map function is defined as this: func Map[E, V any](slice *[]E, i

PHP Laminas PHPStan - Call to an undefined method Laminas\Stdlib\RequestInterface::isPost()

We are running phpstan on a laminas project and running into errors. As an example, in the controller we have some standard code which works fine. $request = $

Is there a way I can break up into more than 2 classes

I am wondering how/if I could possibly break this up into multiple classes but keep the values across objects to pass between both. I am unable to get things wo

how to use if statement in main to Create an object with user input and to use a method on the objects

I'm working on an exercise, where I need to create a subclass that has 2 constructors (1 is empty and sets the values as 0 the other one is getting the values.

Is there "@Deprecated" annotation for methods in .aidl files?

Is there a corresponding "@Deprecated" annotation-syntax for methods in .aidl files? I want to mark a method as deprecated, add a new method and promote the use

How to fix/ learning help understanding basic method and classes, Java code and word Problem

I'm struggling on this problem, given that I'm probably making a basic mistake or I haven't got a clue what I'm doing. platform being a Zybook the problem rea

c# two parameters in one parameter in a method

I would like to make one method like this: public void SomeMethod(int myInt,<float or double or MyClass> myFloatorDoubleorMyClass) { } And not only with

How do I avoid NaN?

I understand it's because the program thinks I'm dividing by O, but I'm not sure how to fix it in the program. The program works fine, though. It outputs the av

How do I return the final discounted price instead of the discounted amount off?

I am creating a method that takes a percent as a parameter and decreases the price by that percent. public void lowerPriceBy(double percent){ price = price/