FAQ Database Discussion Community

Memory consumption when chaining string methods

I know that string in C# is an immutable type. Is it true that when you chain string functions, every function instantiates a new string? If it is true, what is the best practice to do too many manipulations on a string using chaining methods?...

D3.js method chaining command dosn't work when I split it, it works

I am new in D3.js, when i use this code it doesn't work,(it is part of the redraw, when running for first time it works good when calling redraw again it works unexpextedly) var rows=tbody.selectAll('tr').data(roster); rows.enter().append('tr'); rows.exit().remove(); rows.selectAll('td').data(function(row) { return columns.map(function(col) { return row[col]; });}).enter().append('td').text(function(d) {return d;} ); when I...

Mobile first - Encrypted Cache Success and Failure Handler

In MobileFirst V6.3 once we call a JSON Store API, Success and failure can be captured using .then() & .fail(). To chain the API calls we can use multiple .then(). Let's say, WL.JSONStore.startTransaction() .then(function () { var data = [{name: 'carlos'}]; return WL.JSONStore.get(collectionName).add(data); }) .then(function () { var docs =...

Joining a collection based on members of the type

I have a class A and its members b and c. Now I construct the List<A> with this: add(new A().setb("abcd").setc("123456")); add(new A().setb("efgh").setc("789101")); add(new A().setb("ijkl").setc("112345")); I want to transform this List to string which looks like this abcd,123456 efgh,789101 ijkl,112345 Now the very obvious way would be to have a StringBuilder...

How to chain call functions by using a string containing that chain in PHP

I have a chain call like so: $object->getUser()->getName(); I know that I can use a string to call a function on an object: $functionName = 'getUser'; $object->$functionName() or call_user_func(array($object, functionName)) I was wondering if it was possible to do the same for a chain call? I tried to do: $functionName...

How can I break a custom method chain while still returning a value?

I conduct a replace on my search variable turning known groups into group names. I feel like, at each step, I can do a regex match and see if there are two or more group members still in the search query, and if not, abort the chain. This is a...

Chaining not working on jQuery Plugin

I am writing a plugin to pull listings in from my companies internal API and everything is working except for some reason it will not allow me to chain additional methods. (function( $ ) { $.fn.addListings = function(options){ var defaults = { listingCount: 25, pageNumber: 1, customTemp: "<div class='listing'>\ <img...

Make an objects methods chainable in JavaScript

I have been doing battle with this project and understand the concept but cannot get my head wrapped around how to get the end result. Given this code: <!doctype html> <html> <head> <title> Make an objects methods chainable </title> <meta charset="utf-8"> <script> function modifyFunction(f) { return function() { var returnValue...

Fluent Groovy syntax using command chaining and maps

Given the following Groovy code: someMap = ['key':{ str -> println "SUCCESS: ${str}" }] clos = { someMap } All of the following are legal ways to print SUCCESS: abc: clos(null)['key'] "abc" clos null key "abc" someMap['key'] "abc" This one, however: someMap key "abc" throws a groovy.lang.MissingPropertyException: No such property:...

What is the name of the design pattern used in method chaining in jQuery? [closed]

I want to know what is the name of the design pattern behind method chaining in jQuery?

JavaScript/jQuery: How to Chain a Method that uses console.log()

I'm playing around with jQuery plugin development, and I'd like to chain methods. I read in the jQuery tutorial (https://learn.jquery.com/plugins/basic-plugin-creation/) that you can chain methods by adding return this; to the end of the method, and that works for the first method (test 1). How can I do that for...