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.

493 questions
10
votes
1 answer

How do you use underscore's chain method to return the first item in a multidimensional array?

Say I have an array of arrays, and I want to return the first element of each array within the array: array = [[["028A","028B","028C","028D","028E"], ["028F","0290","0291","0292","0293"], ["0294","0295","0296","0297","0298"], …
Chris Matta
  • 2,640
  • 3
  • 28
  • 45
9
votes
2 answers

itertools.chain to chain an iter list?

import itertools def _yield_sample(): it = iter(itertools.combinations('ABCD', 2)) it2 = iter(itertools.combinations('EFGH', 3)) itc = itertools.chain(it,it2) for x in itc: yield x def main(): for x in _yield_sample(): …
user478514
  • 3,297
  • 8
  • 30
  • 39
9
votes
8 answers

How to stop writing chain code?

for example... if ( /* Condition */ ) { if ( /* Condition */ ) { if ( /* Condition */ ) { // Superb! } else { // Error 3 } } else { // Error 2 } } else { // Error 1 } Do…
Ryan Zygg
  • 331
  • 1
  • 3
  • 8
9
votes
12 answers

How better refactor chain of methods that can return null in java?

I have code like: obj1 = SomeObject.method1(); if (obj1 != null) { obj2 = obj1.method2(); if (obj2 != null) { obj3 = obj2.method3(); if (obj3 != null) { ............ return objN.methodM(); } } } .... I have…
user710818
  • 20,710
  • 55
  • 138
  • 197
9
votes
4 answers

(Hadoop) MapReduce - Chain jobs - JobControl doesn't stop

I need to chain two MapReduce jobs. I used JobControl to set job2 as dependent of job1. It works, output files are created!! But it doesn't stop! In the shell it remains in this state: 12/09/11 19:06:24 WARN mapred.JobClient: Use…
Pietro Luciani
  • 237
  • 1
  • 4
  • 14
9
votes
2 answers

How do I do JavaScript Prototype Inheritance (chain of prototypes)

This is a question for the guru of JavaScript. I'm trying to do work with JavaScript prototype model more elegant. Here is my utility code (it provides real chain of prototypes and correct work with instanceof operator): function Class(conf) { var…
Danil Speransky
  • 27,720
  • 3
  • 57
  • 71
8
votes
3 answers

How can I chain together filename modifiers in a bash shell?

I understand the modifiers # ## % %%, but I can't figure out if its possible to chain them together as you can in tcsh. Example in tcsh set f = /foo/bar/myfile.0076.jpg echo $f:r:e --> 0076 echo $f:h:t --> bar In bash, I'd like to know how to do…
Julian Mann
  • 5,377
  • 4
  • 27
  • 41
8
votes
2 answers

How can I sequentially chain promises using bluebirdjs?

Promise.all() doesn't guarantee that promises will be resolved in order. How can this be done?
redgeoff
  • 2,675
  • 1
  • 20
  • 38
8
votes
2 answers

android parcelable referencing another parcelable circular dependence

Rather simple scenario really, but I could not find anything related on Google so here goes: class ContainerClass implements Parcelable { List _items; (...) public void writeToParcel( Parcel p, int args ) { p.writeList( _items…
Skod
  • 145
  • 1
  • 6
7
votes
3 answers

CXF WS, Interceptor: stop processing, respond with fault

I'm scratching my head over this: Using an Interceptor to check a few SOAP headers, how can I abort the interceptor chain but still respond with an error to the user? Throwing a Fault works regarding the output, but the request is still being…
Alex
  • 422
  • 7
  • 16
7
votes
2 answers

How to share tasks between vscode workspace folders?

My VSCode project is multi-root workspace. That is I have multiple workspaces each in separate directories, each has a .vscode folder. I'm trying to build a workspace with dependencies between each module via build tasks. I've tried to set dependsOn…
alex
  • 303
  • 2
  • 16
7
votes
2 answers

Chain a celery task's results into a distributed group

Like in this other question, I want to create a celery group from a list that's returned by a celery task. The idea is that the first task will return a list, and the second task will explode that list into concurrent tasks for every item in the…
mlissner
  • 14,662
  • 15
  • 82
  • 149
7
votes
1 answer

What's the alternative to pandas chain indexing?

I'm taking an online class to learn python and the instructor taught us that chain indexing was not a good idea. However, he failed to tell is the appropriate alternative to use. Suppose I have a Pandas data frame with rows indexed as ['1', '2',…
RosieMB
  • 71
  • 1
  • 5
7
votes
1 answer

Unable to specify certificate chain for AuthenticateAsServer?

I'm struggling with the apparent lack of flexibility in SslStream AuthenticateAsServer. I have a self-signed rootCA, an intermediate CA, and an end-entity (host) certificate. I am only doing server authentication. The client has the rootCA cert…
user1169420
  • 446
  • 3
  • 14
7
votes
1 answer

Typescript and the __proto__ attribute

So every mention of __proto__ is usually followed by a reference to Brendan Eich's plea not to use it. I've been playing around with some reflection in Typescript, navigating the prototype chain of a class down to a provided ancestor class using it,…
Frostie
  • 201
  • 3
  • 6
1
2
3
32 33