Questions tagged [extend]

Cause a unit of code (a class in POO, a style class in CSS ...) to cover a wider area.

Cause a unit of code (a class in POO, a style class in CSS ...) to cover a wider area.

1478 questions
3114
votes
20 answers

What is the difference between Python's list methods append and extend?

What's the difference between the list methods append() and extend()?
Claudiu
  • 206,738
  • 150
  • 445
  • 651
436
votes
6 answers

What is the difference between include and extend in Ruby?

Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. include: mixes in specified module methods as instance methods in the target class extend: mixes in specified module methods as class methods in the…
Gishu
  • 126,803
  • 45
  • 214
  • 298
218
votes
6 answers

What is the syntax to insert one list into another list in python?

Given two lists: x = [1,2,3] y = [4,5,6] What is the syntax to: Insert x into y such that y now looks like [1, 2, 3, [4, 5, 6]]? Insert all the items of x into y such that y now looks like [1, 2, 3, 4, 5, 6]?
Soumya
  • 4,784
  • 7
  • 27
  • 29
162
votes
9 answers

Rails extending ActiveRecord::Base

I've done some reading about how to extend ActiveRecord:Base class so my models would have some special methods. What is the easy way to extend it (step by step tutorial)?
xpepermint
  • 31,091
  • 29
  • 106
  • 160
103
votes
7 answers

Javascript: Extend a Function

The main reason why I want it is that I want to extend my initialize function. Something like this: // main.js window.onload = init(); function init(){ doSomething(); } // extend.js function extends init(){ doSomethingHereToo(); } So I…
Adam Halasz
  • 51,803
  • 63
  • 138
  • 208
98
votes
8 answers

JavaScript equivalent of jQuery's extend method

Background I have a function that takes a config object as an argument. Within the function, I also have default object. Each of those objects contains properties that essentially work as settings for the rest of the code within the function. In…
mbeasley
  • 4,584
  • 4
  • 24
  • 38
96
votes
2 answers

Does LESS have an "extend" feature?

SASS has a feature called @extend which allows a selector to inherit the properties of another selector, but without copying the properties (like mixins). Does LESS have this feature as well?
jonschlinkert
  • 10,046
  • 3
  • 38
  • 50
95
votes
2 answers

When to implement and extend?

When should implement or extend be used? What are some real-world examples? Is this correct? Implementing appears to be a way to enforce that certain methods exists in a class, and that these methods function calls are properly formatted.…
Industrial
  • 36,181
  • 63
  • 182
  • 286
84
votes
5 answers

Difference between jQuery.extend and jQuery.fn.extend?

I am trying to understand the jquery plugin syntax, because I want to merge two plugins into one. The blinker that also needs to be able to stop de interval or run a number of times. Anyway, is this syntax the same as jQuery.fn.extend({ …
Richard
  • 4,348
  • 11
  • 57
  • 86
77
votes
7 answers

Best Way to Extend a jQuery Plugin

I'm a fairly new jQuery user looking to extend an existing jQuery plugin that does about 75% of what I need. I've tried to do my homework on this. I've checked out the following questions on stackoverflow: Extending a jQuery Plugin Extend a…
justkt
  • 13,970
  • 8
  • 39
  • 61
65
votes
7 answers

Appending a list to a list of lists in R

I'm having issues appending data to a list which is already in a list format. I have a program which will export results objects during a simulation loop. The data itself is stored as a list of matrices. My idea is to store those lists in a list,…
Ward9250
  • 3,247
  • 5
  • 34
  • 50
62
votes
4 answers

jquery extend vs angular extend

What is the difference between these two extend functions? angular.extend(a,b); $.extend(a,b); While the jquery.extend is well documented the angular.extend lacks details and the comments there provide no answers.…
Renaud
  • 4,193
  • 7
  • 36
  • 61
43
votes
11 answers

deep extend (like jQuery's) for nodeJS

I am struggling with deep copies of objects in nodeJS. my own extend is crap. underscore's extend is flat. there are rather simple extend variants here on stackexchange, but none are even close to jQuery.extend(true, {}, obj, obj, obj) .. (most are…
itsatony
  • 957
  • 1
  • 8
  • 13
41
votes
2 answers

Extending an existing jQuery function

I am trying to write a plugin that will extend an existing function in jQuery, e.g. (function($) { $.fn.css = function() { // stuff I will be extending // that doesn't affect/change // the way .css() works …
MacMac
  • 30,042
  • 53
  • 142
  • 217
40
votes
8 answers

Ways to extend Array object in javascript

i try to extend Array object in javascript with some user friendly methods like Array.Add() instead Array.push() etc... i implement 3 ways to do this. unfortunetly the 3rd way is not working and i want to ask why? and how to do it…
demosthenes
  • 998
  • 1
  • 11
  • 17
1
2 3
98 99