Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Mixins

< >
Example from 1 languages: Python
# https://easyaspython.com/mixins-for-fun-and-profit-cb9962760556 class EssentialFunctioner(LoggerMixin, object):
Example from 1 languages: Ruby
module A def a1 end def a2 end end module B def b1 end def b2 end end class Sample include A include B def s1 end end samp = Sample.new samp.a1 samp.a2 samp.b1
Example from 1 languages: TypeScript
// https://www.typescriptlang.org/docs/handbook/mixins.html class SmartObject implements Disposable, Activatable { } // Note: still need to do some runtime ops to make that work.
Example from 1 languages: Julia
# Including the same code in different modules provides mixin-like behavior. module Normal include("mycode.jl") end module Testing include("safe_operators.jl") include("mycode.jl") end
Example from 1 languages: Racket
(mixin (interface-expr ...) (interface-expr ...) class-clause ...)
Example from 1 languages: Sass
@mixin reset-list margin: 0 padding: 0 list-style: none @mixin horizontal-list @include reset-list li display: inline-block margin: left: -2px right: 2em nav ul @include horizontal-list
Example from 1 languages: SCSS
@mixin reset-list { margin: 0; padding: 0; list-style: none; } @mixin horizontal-list { @include reset-list; li { display: inline-block; margin: { left: -2px; right: 2em; } } } nav ul { @include horizontal-list; }
Example from 1 languages: Xtext
grammar org.example.domainmodel.Domainmodel with org.eclipse.xtext.common.Terminals
*

Languages with Mixins include Python, Ruby, TypeScript, Julia, Racket, Sass, SCSS, Xtext

*

Languages without Mixins include CSS

*

View all concepts with or missing a hasMixins measurement

*

Read more about Mixins on the web: 1.

- Build the next great programming language Add Issues About Search Keywords Livestreams Labs Resources Acknowledgements