Questions tagged [chain]

Use the tag "method-chaining' if referring to the invocation of multiple methods against a single object. Chaining is the general idea of linking many smaller processes together to form a large process.

Method Chaining allows you to run multiple methods against an object on one line of code.

For example in Java the methods setName and setAge are chained:

Person person = new Person();        //instantiate a new person object.
person.setName("Peter").setAge(21);  //set the name, and age of object person.

First the method setName is applied to the object, then setAge.

Each method returns an object, allowing any number of calls to be chained together in a single statement.

561 questions
-1
votes
1 answer

Big O complexity of the cases (answers provided- confirmation would be awesome!)

Question: We have a chain (or a linked list) of integers with 2-field records: an integer field and a pointer field. If there are n items in a given list, what is the Big O complexity of each of the following cases? -- Note that the chain is not…
-1
votes
4 answers

General C program

The following code; typedef struct chainCell{ int data; struct chainCell* next; } chainCell; bool sameValues (chainCell *x, chainCell *y) { if ((x == NULL) & (y == NULL)) return true; if ((x == NULL) | (y == NULL)) return false; bool…
CBreeze
  • 2,925
  • 4
  • 38
  • 93
-1
votes
4 answers

Why do I always get an ArrayIndexOutOfBoundsException?

This code is taken from a common algorithms book. The book uses an array starting from 1 instead of 0 for m but starts from 0 for p. How do I solve it ?? These are the errors: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at…
-2
votes
6 answers

Which method is called during Constructor chain execution with an overriding method

Which method is called during Constructor chain execution with an overriding method? Given the following two classes I need to know which setGear method would be called when creating a MountainBike object. My real project has nothing to do with…
Steve
  • 13
  • 3
-2
votes
1 answer

How to make a chain calculation using OOP?

Given MyCalculator class class MyCalculator { public float $a, $b, $c, public MyCalculator $result; public function __construct ($a, $b) { $this->a = $a; $this->b = $b; $this->result =…
Max
  • 3
  • 4
-2
votes
1 answer

javascript promise chain with fetch not in sequence

I want to dynamically build a promise chain, that should do things in the background. Mainly it should do some output on the web page. That works until I put promises from fetch into the chain. Those promises are not executed in the expected…
Tobias Wollgam
  • 761
  • 2
  • 8
  • 25
-2
votes
1 answer

How to make a chain of conditions for a Promise

I have a function checkAge(age) which takes the user's age. The function checks whether the set age parameter is set correctly, if it is set incorrectly, the corresponding error should be generated and displayed in the console. I have some…
intern
  • 25
  • 5
-2
votes
3 answers

What do I have to change in my code to work?

I do not know what is the problem with my code. Can I get some help to understand it ? Use longestChain to see how long the longest string in a text is made up of identical characters! Examples: longestChain "2111234" == 3 longestChain…
topi12
  • 37
  • 5
-2
votes
1 answer

I don't understand how this line works: "System.out.println("\nCard: " + Deck.get(number).getValue() + " of " + Deck.get(number).getSuit() );"

The code below is a code shared with me by someone who I can't reach right now. I'm still new to array listing, method chaining, and pretty much to coding as well. I tried converting the "Deck.get(number).getValue()" into "Deck.getValue()" and some…
-2
votes
1 answer

CORDA Development

I need to implement CORDA Block Chain in our performance appraisal application which is developed in .Net Core and angular. Please guide us the structure and how to use it. Your reply is really appreciated. Thanks, Kopal Rajpoot
-2
votes
1 answer

Need to implement the Python itertools function "chain" in a class

I am trying to emulate the "chain" function in itertools in python. I came up with the following generator. # Chain make an iterator that returns elements from the first iterable # until it is exhausted, then proceeds to the next iterable, until…
Farrousa
  • 149
  • 1
  • 11
-2
votes
1 answer

Ruby check if method chaining is valud

Suppose I have an Active Record class. If I have: Houses, which has many People, who have many Dogs, who have many Collars. I will not do the schema definitions as they are trivial. Now I want from a page where I have a house object to iterate…
Axiombadger
  • 161
  • 10
-2
votes
1 answer

Sort a student structure chain: sortbyScore function

Solved below I try to use student structure to create a student chain and do some delete and insert student things. But encountered the errors below. Any body could solve this problem? All the source code are posted at the end. * Remaining…
Bruce Yo
  • 152
  • 1
  • 12
-3
votes
1 answer

How can I start to solve a word chain in haskell?

Let us know if the word chain game was played correctly! The object of the game is to form another word with the last letter of the previous word. The words are separated by a space. The words function can help you solve this problem. Each of the…
hello16
  • 43
  • 4
-3
votes
1 answer

Java object set chain command

Is there a plugin or a tool you can use to simply add this method to the Object class in java? public this set(Object o){ this = o; return this; }
1 2 3
37
38