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.

1544 questions
3112
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
  • 224,032
  • 165
  • 485
  • 680
480
votes
7 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
  • 134,492
  • 47
  • 225
  • 308
232
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
  • 5,262
  • 8
  • 31
  • 30
168
votes
12 answers

How to override and extend basic Django admin templates?

How do I override an admin template (e.g. admin/index.html) while at the same time extending it (see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template)? First - I know that this question has been…
Semmel
  • 2,526
  • 3
  • 21
  • 30
161
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
  • 35,055
  • 30
  • 109
  • 163
116
votes
8 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
  • 57,421
  • 66
  • 149
  • 213
111
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,864
  • 5
  • 27
  • 39
109
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
  • 41,400
  • 69
  • 194
  • 289
100
votes
3 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,872
  • 4
  • 43
  • 50
88
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,516
  • 11
  • 60
  • 87
78
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
  • 14,610
  • 8
  • 42
  • 62
78
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,…
SJWard
  • 3,629
  • 5
  • 39
  • 54
63
votes
3 answers

How to extend a typedef parameter in JSDOC?

Assuming you have the following code inside a ES6 class (documentation): /** * @typedef Test~options * @type {object.} * @property {array} elements - An array containing elements * @property {number} length - The array length */ /** *…
dude
  • 5,678
  • 11
  • 54
  • 81
63
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,569
  • 7
  • 41
  • 72
47
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
  • 1,151
  • 1
  • 13
  • 17
1
2 3
99 100