What is an object in Ruby?

In Ruby, several objects can be considered function objects, in particular Method and Proc objects. Ruby also has two kinds of objects that can be thought of as semi-function objects: UnboundMethod and block. UnboundMethods must first be bound to an object (thus becoming a Method) before they can be used as a function object. Blocks can be called like function objects, but to be used in any other capacity as an object (e.g. passed as an argument) they must first be converted to a Proc. More recently, symbols (accessed via the literal unary indicator codice_35) can also be converted to codice_36s. Using Ruby's unary codice_37 operator—equivalent to calling codice_38 on an object, and assuming that method exists—the Ruby Extensions Project created a simple hack.

Function object

In computer programming, a function object is a construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax (a function parameter that can also be a function). Function objects are often called functors.

A typical use of a function object is in writing callback functions. A callback in procedural languages, such as C, may be performed by using function pointers. However it can be difficult or awkward to pass a state into or out of the callback function. This restriction also inhibits more dynamic behavior of the function. A function object solves those problems since the function is really a façade for a full object, carrying its own state.

Many modern (and some older) languages, e.g. C++, Eiffel, Groovy, Lisp, Smalltalk, Perl, PHP, Python, Ruby, Scala, and many others, support first-class function objects and may even make significant use of them. Functional programming languages additionally support closures, i.e. first-class functions that can 'close over' variables in their surrounding environment at creation time. During compilation, a transformation known as lambda lifting converts the closures into function objects.

Consider the example of a sorting routine that uses a callback function to define an ordering relation between a pair of items. A C program using function pointers may appear as:

In C++, a function object may be used instead of an ordinary function by defining a class that overloads the function call operator by defining an codice_1 member function. In C++, this may appear as follows:

Notice that the syntax for providing the callback to the codice_2 function is identical, but an object is passed instead of a function pointer. When invoked, the callback function is executed just as any other member function, and therefore has full access to the other members (data or functions) of the object. Of course, this is just a trivial example. To understand what power a functor provides more than a regular function, consider the common use case of sorting objects by a particular field. In the following example, a functor is used to sort a simple employee database by each employee's ID number.

In C++11, the lambda expression provides a more succinct way to do the same thing.

It is possible to use function objects in situations other than as callback functions. In this case, the shortened term "functor" is normally "not" used about the function object. Continuing the example,

In addition to class type functors, other kinds of function objects are also possible in C++. They can take advantage of C++'s member-pointer or template facilities. The expressiveness of templates allows some functional programming techniques to be used, such as defining function objects in terms of other function objects (like function composition). Much of the C++ Standard Template Library (STL) makes heavy use of template-based function objects.

Another advantage of function objects is their ability to maintain a state that affects codice_1 between calls. For example, the following code defines a generator counting from 10 upwards and is invoked 11 times.

In C#, function objects are declared via delegates. A delegate can be declared using a named method or a lambda expression. Here is an example using a named method.

Here is an example using a lambda expression.

D provides several ways to declare function objects: Lisp/Python-style via closures or C#-style via delegates, respectively:

The difference between a delegate and a closure in D is automatically and conservatively determined by the compiler. D also supports function literals, that allow a lambda-style definition:

To allow the compiler to inline the code (see above), function objects can also be specified C++-style via operator overloading:

In the Eiffel software development method and language, operations and objects are seen always as separate concepts. However, the agent mechanism facilitates the modeling of operations as runtime objects. Agents satisfy the range of application attributed to function objects, such as being passed as arguments in procedural calls or specified as callback routines. The design of the agent mechanism in Eiffel attempts to reflect the object-oriented nature of the method and language. An agent is an object that generally is a direct instance of one of the two library classes, which model the two types of routines in Eiffel: codice_4 and codice_5. These two classes descend from the more abstract codice_6.

Within software text, the language keyword codice_7 allows agents to be constructed in a compact form. In the following example, the goal is to add the action of stepping the gauge forward to the list of actions to be executed in the event that a button is clicked.

The routine codice_8 referenced in the example above is a feature of a class in a graphical user interface (GUI) library to provide event-driven programming capabilities.

In other library classes, agents are seen to be used for different purposes. In a library supporting data structures, for example, a class modeling linear structures effects universal quantification with a function codice_9 of type codice_10 that accepts an agent, an instance of codice_5, as an argument. So, in the following example, codice_12 is executed only if all members of codice_13 contain the character '!':

When agents are created, the arguments to the routines they model and even the target object to which they are applied can be either "closed" or left "open". Closed arguments and targets are given values at agent creation time. The assignment of values for open arguments and targets is deferred until some point after the agent is created. The routine codice_9 expects as an argument an agent representing a function with one open argument or target that conforms to actual generic parameter for the structure (codice_15 in this example.)

When the target of an agent is left open, the class name of the expected target, enclosed in braces, is substituted for an object reference as shown in the text codice_16 in the example above. When an argument is left open, the question mark character ('?') is coded as a placeholder for the open argument.

The ability to close or leave open targets and arguments is intended to improve the flexibility of the agent mechanism. Consider a class that contains the following procedure to print a string on standard output after a new line:

The following snippet, assumed to be in the same class, uses codice_17 to demonstrate the mixing of open arguments and open targets in agents used as arguments to the same routine.

This example uses the procedure codice_18 for linear structures, which executes the routine modeled by an agent for each item in the structure.

The sequence of three instructions prints the strings in codice_13, converts the strings to lowercase, and then prints them again.

Procedure codice_18 iterates across the structure executing the routine substituting the current item for either the open argument (in the case of the agents based on codice_17), or the open target (in the case of the agent based on codice_22).

Open and closed arguments and targets also allow the use of routines that call for more arguments than are required by closing all but the necessary number of arguments:

The Eiffel agent mechanism is detailed in the Eiffel ISO/ECMA standard document.

Java has no first-class functions, so function objects are usually expressed by an interface with a single method (most commonly the codice_23 interface), typically with the implementation being an anonymous inner class, or, starting in Java 8, a lambda.

For an example from Java's standard library, codice_24 takes a codice_25 and a functor whose role is to compare objects in the List. Without first-class functions, the function is part of the Comparator interface. This could be used as follows.

In Java 8+, this can be written as:
In JavaScript, functions are first class objects. JavaScript also supports closures.

Compare the following with the subsequent Python example.

An example of this in use:

In Julia, methods are associated with types, so it is possible to make any arbitrary Julia object "callable" by adding methods to its type. (Such "callable" objects are sometimes called "functors.")

An example is this accumulator mutable struct (based on Paul Graham's study on programming language syntax and clarity):

Such an accumulator can also be implemented using closure:

In Lisp family languages such as Common Lisp, Scheme, and others, functions are objects, just like strings, vectors, lists, and numbers. A closure-constructing operator creates a "function object" from a part of the program: the part of code given as an argument to the operator is part of the function, and so is the lexical environment: the bindings of the lexically visible variables are "captured" and stored in the function object, which is more commonly called a closure. The captured bindings play the role of "member variables", and the code part of the closure plays the role of the "anonymous member function", just like operator () in C++.

The closure constructor has the syntax codice_26. The codice_27 part allows an interface to be declared, so that the function takes the declared parameters. The codice_28 part consists of expressions that are evaluated when the functor is called.

Many uses of functors in languages like C++ are simply emulations of the missing closure constructor. Since the programmer cannot directly construct a closure, they must define a class that has all of the necessary state variables, and also a member function. Then, construct an instance of that class instead, ensuring that all the member variables are initialized through its constructor. The values are derived precisely from those local variables that ought to be captured directly by a closure.

A function-object using the class system, no use of closures:

Since there is no standard way to make funcallable objects in Lisp, we fake it by defining a generic function called FUNCTOR-CALL. This can be specialized for any class whatsoever. The standard FUNCALL function is not generic; it only takes function objects.

It is this FUNCTOR-CALL generic function that gives us function objects, which are "a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax." We have "almost" the same syntax: FUNCTOR-CALL instead of FUNCALL. Some Lisps provide "funcallable" objects as a simple extension. Making objects callable using the same syntax as functions is a fairly trivial business. Making a function call operator work with different kinds of "function things", whether they be class objects or closures is no more complicated than making a + operator that works with different kinds of numbers, such as integers, reals or complex numbers.

Now, a counter implemented using a closure. This is much more brief and direct. The INITIAL-VALUE argument of the MAKE-COUNTER factory function is captured and used directly. It does not have to be copied into some auxiliary class object through a constructor. It "is" the counter. An auxiliary object is created, but that happens "behind the scenes".

Scheme makes closures even simpler, and Scheme code tends to use such higher-order programming somewhat more idiomatically.

More than one closure can be created in the same lexical environment. A vector of closures, each implementing a specific kind of operation, can quite faithfully emulate an object that has a set of virtual operations. That type of single dispatch object-oriented programming can be done fully with closures.

Thus there exists a kind of tunnel being dug from both sides of the proverbial mountain. Programmers in OOP languages discover function objects by restricting objects to have one "main" function to "do" that object's functional purpose, and even eliminate its name so that it looks like the object is being called! While programmers who use closures are not surprised that an object is called like a function, they discover that multiple closures sharing the same environment can provide a complete set of abstract operations like a virtual table for single dispatch type OOP.

In Objective-C, a function object can be created from the codice_29 class. Construction of a function object requires a method signature, the target object, and the target selector. Here is an example for creating an invocation to the current object's codice_30:

An advantage of codice_29 is that the target object can be modified after creation. A single codice_29 can be created and then called for each of any number of targets, for instance from an observable object. An codice_29 can be created from only a protocol, but it is not straightforward. See here.

In Perl, a function object can be created either from a class's constructor returning a function closed over the object's instance data, blessed into the class:

or by overloading the &{} operator so that the object can be used as a function:

In both cases the function object can be used either using the dereferencing arrow syntax "$ref->(@arguments)":
or using the coderef dereferencing syntax "&$ref(@arguments)":

PHP 5.3+ has first-class functions that can be used e.g. as parameter to the usort() function:

It is also possible in PHP 5.3+ to make objects invokable by adding a magic __invoke() method to their class:

In the Windows PowerShell language, a script block is a collection of statements or expressions that can be used as a single unit. A script block can accept arguments and return values. A script block is an instance of a Microsoft.NET Framework type System.Management.Automation.ScriptBlock.

In Python, functions are first-class objects, just like strings, numbers, lists etc. This feature eliminates the need to write a function object in many cases. Any object with a codice_34 method can be called using function-call syntax.

An example is this accumulator class (based on Paul Graham's study on programming language syntax and clarity):

An example of this in use (using the interactive interpreter):

Since functions are objects, they can also be defined locally, given attributes, and returned by other functions
, as demonstrated in the following example:

Now, method codice_39 can be a function object, i.e. a codice_36, via codice_41 and used via codice_42. codice_43 was officially added to Ruby on June 11, 2006 during RubyKaigi2006.

Because of the variety of forms, the term Functor is not generally used in Ruby to mean a Function object.
Just a type of dispatch delegation introduced by the Ruby Facets project is named as Functor. The most basic definition of which is:

This usage is more akin to that used by functional programming languages, like ML, and the original mathematical terminology.

In a more theoretical context a "function object" may be considered to be any instance of the class of functions, especially in languages such as Common Lisp in which functions are first-class objects.

The ML family of functional programming languages uses the term "functor" to represent a mapping from modules to modules, or from types to types and is a technique for reusing code. Functors used in this manner are analogous to the original mathematical meaning of functor in category theory, or to the use of generic programming in C++, Java or Ada.

In Haskell, the term is used in the same sense as in category theory.

In Prolog and related languages, "functor" is a synonym for function symbol.

Matsumoto defined it this way in an interview:Ruby is object-oriented: every value is an object, including classes and instances of types that many other languages designate as primitives (such as integers, booleans, and "null"). Variables always hold references to objects. Every function is a method and methods are always called on an object. Methods defined at the top level scope become methods of the Object class. Since this class is an ancestor of every other class, such methods can be called on any object. They are also visible in all scopes, effectively serving as "global" procedures. Ruby supports inheritance with dynamic dispatch, mixins and singleton methods (belonging to, and defined for, a single instance rather than being defined on the class). Though Ruby does not support multiple inheritance, classes can import modules as mixins.

Ruby (programming language)

Ruby is a dynamic, interpreted,
reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

According to the creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. It supports multiple programming paradigms, including functional, object-oriented, and imperative. It also has a dynamic type system and automatic memory management.

Matsumoto has said that Ruby was conceived in 1993. In a 1999 post to the "ruby-talk" mailing list, he describes some of his early ideas about the language:

Matsumoto describes the design of Ruby as being like a simple Lisp language at its core, with an object system like that of Smalltalk, blocks inspired by higher-order functions, and practical utility like that of Perl.

The name "Ruby" originated during an online chat session between Matsumoto and Keiju Ishitsuka on February 24, 1993, before any code had been written for the language. Initially two names were proposed: "Coral" and "Ruby". Matsumoto chose the latter in a later e-mail to Ishitsuka. Matsumoto later noted a factor in choosing the name "Ruby" – it was the birthstone of one of his colleagues.

The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995. Subsequently, three more versions of Ruby were released in two days. The release coincided with the launch of the Japanese-language "ruby-list" mailing list, which was the first mailing list for the new language.

Already present at this stage of development were many of the features familiar in later releases of Ruby, including object-oriented design, classes with inheritance, mixins, iterators, closures, exception handling and garbage collection.

Following the release of Ruby 0.95 in 1995, several stable versions of Ruby were released in the following years:

In 1997, the first article about Ruby was published on the Web. In the same year, Matsumoto was hired by netlab.jp to work on Ruby as a full-time developer.

In 1998, the Ruby Application Archive was launched by Matsumoto, along with a simple English-language homepage for Ruby.

In 1999, the first English language mailing list "ruby-talk" began, which signaled a growing interest in the language outside Japan. In this same year, Matsumoto and Keiju Ishitsuka wrote the first book on Ruby, "The Object-oriented Scripting Language Ruby" (オブジェクト指向スクリプト言語 Ruby), which was published in Japan in October 1999. It would be followed in the early 2000s by around 20 books on Ruby published in Japanese.

By 2000, Ruby was more popular than Python in Japan. In September 2000, the first English language book "Programming Ruby" was printed, which was later freely released to the public, further widening the adoption of Ruby amongst English speakers. In early 2002, the English-language "ruby-talk" mailing list was receiving more messages than the Japanese-language "ruby-list", demonstrating Ruby's increasing popularity in the non-Japanese speaking world.

Ruby 1.8 was initially released August 2003, was stable for a long time, and was retired June 2013. Although deprecated, there is still code based on it. Ruby 1.8 is only partially compatible with Ruby 1.9.

Ruby 1.8 has been the subject of several industry standards. The language specifications for Ruby were developed by the Open Standards Promotion Center of the Information-Technology Promotion Agency (a Japanese government agency) for submission to the Japanese Industrial Standards Committee (JISC) and then to the International Organization for Standardization (ISO). It was accepted as a Japanese Industrial Standard (JIS X 3017) in 2011 and an international standard (ISO/IEC 30170) in 2012.

Around 2005, interest in the Ruby language surged in tandem with Ruby on Rails, a web framework written in Ruby. Rails is frequently credited with increasing awareness of Ruby.

Ruby 1.9 was released on Christmas Day in 2007. Effective with Ruby 1.9.3, released October 31, 2011, Ruby switched from being dual-licensed under the Ruby License and the GPL to being dual-licensed under the Ruby License and the two-clause BSD license. Adoption of 1.9 was slowed by changes from 1.8 that required many popular third party gems to be rewritten.

Ruby 1.9 introduces many significant changes over the 1.8 series. Examples:

Ruby 1.9 has been obsolete since February 23, 2015, and it will no longer receive bug and security fixes. Users are advised to upgrade to a more recent version.

Ruby 2.0 added several new features, including:

Ruby 2.0 is intended to be fully backward compatible with Ruby 1.9.3. As of the official 2.0.0 release on February 24, 2013, there were only five known (minor) incompatibilities.

It has been obsolete since February 22, 2016, and it will no longer receive bug and security fixes. Users are advised to upgrade to a more recent version.

Ruby 2.1.0 was released on Christmas Day in 2013. The release includes speed-ups, bugfixes, and library updates.

Starting with 2.1.0, Ruby's versioning policy is more like semantic versioning. Although similar, Ruby's versioning policy is not compatible with semantic versioning:

Semantic versioning also provides additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, not available at Ruby.

Ruby 2.1 has been obsolete since April 1, 2017, and it will no longer receive bug and security fixes. Users are advised to upgrade to a more recent version.

Ruby 2.2.0 was released on Christmas Day in 2014. The release includes speed-ups, bugfixes, and library updates and removes some deprecated APIs. Most notably, Ruby 2.2.0 introduces changes to memory handling an incremental garbage collector, support for garbage collection of symbols and the option to compile directly against jemalloc. It also contains experimental support for using vfork(2) with system() and spawn(), and added support for the Unicode 7.0 specification.

Features that were made obsolete or removed include callcc, the DL library, Digest::HMAC, lib/rational.rb, lib/complex.rb, GServer, Logger::Application as well as various C API functions.Ruby 2.3.0 was released on Christmas Day in 2015. A few notable changes include:

The 2.3 branch also includes many performance improvements, updates, and bugfixes including changes to Proc#call, Socket and IO use of exception keywords, Thread#name handling, default passive Net::FTP connections, and Rake being removed from stdlib.

Ruby 2.4.0 was released on Christmas Day in 2016. A few notable changes include:The 2.4 branch also includes performance improvements to hash table, Array#max, Array#min, and instance variable access.

Ruby's popularity has been declining since 2014, a slip that may be permanent in the face of increasing competition.

Ruby 2.5.0 was released on Christmas Day in 2017. A few notable changes include:On top of that come a lot of performance improvements like faster block passing (3 times faster), faster Mutexes, faster ERB templates and improvements on some concatenation methods.

Ruby 2.6.0 was released on Christmas Day in 2018. A few notable changes include:Matsumoto has said that Ruby is designed for programmer productivity and fun, following the principles of good user interface design. At a Google Tech Talk in 2008 Matsumoto further stated, "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language." He stresses that systems design needs to emphasize human, rather than computer, needs:

Ruby is said to follow the principle of least astonishment (POLA), meaning that the language should behave in such a way as to minimize confusion for experienced users. Matsumoto has said his primary design goal was to make a language that he himself enjoyed using, by minimizing programmer work and possible confusion. He has said that he had not applied the principle of least astonishment to the design of Ruby, but nevertheless the phrase has come to be closely associated with the Ruby programming language. The phrase has itself been a source of surprise, as novice users may take it to mean that Ruby's behaviors try to closely match behaviors familiar from other languages. In a May 2005 discussion on the newsgroup comp.lang.ruby, Matsumoto attempted to distance Ruby from POLA, explaining that because any design choice will be surprising to someone, he uses a personal standard in evaluating surprise. If that personal standard remains consistent, there would be few surprises for those familiar with the standard.

Ruby has been described as a multi-paradigm programming language: it allows procedural programming (defining functions/variables outside classes makes them part of the root,'self' Object), with object orientation (everything is an object) or functional programming (it has anonymous functions, closures, and continuations; statements all have values, and functions return the last evaluation). It has support for introspection, reflection and metaprogramming, as well as support for interpreter-based threads. Ruby features dynamic typing, and supports parametric polymorphism.

According to the Ruby FAQ, the syntax is similar to Perl and the semantics are similar to Smalltalk, but it differs greatly from Python.

The syntax of Ruby is broadly similar to that of Perl and Python. Class and method definitions are signaled by keywords, whereas code blocks can be both defined by keywords or braces. In contrast to Perl, variables are not obligatorily prefixed with a sigil. When used, the sigil changes the semantics of scope of the variable. For practical purposes there is no distinction between expressions and statements. Line breaks are significant and taken as the end of a statement; a semicolon may be equivalently used. Unlike Python, indentation is not significant.

One of the differences from Python and Perl is that Ruby keeps all of its instance variables completely private to the class and only exposes them through accessor methods (codice_11, codice_12, etc.). Unlike the "getter" and "setter" methods of other languages like C++ or Java, accessor methods in Ruby can be created with a single line of code via metaprogramming; however, accessor methods can also be created in the traditional fashion of C++ and Java. As invocation of these methods does not require the use of parentheses, it is trivial to change an instance variable into a full function, without modifying a single line of calling code or having to do any refactoring achieving similar functionality to C# and VB.NET property members.

Python's property descriptors are similar, but come with a tradeoff in the development process. If one begins in Python by using a publicly exposed instance variable, and later changes the implementation to use a private instance variable exposed through a property descriptor, code internal to the class may need to be adjusted to use the private variable rather than the public property. Ruby’s design forces all instance variables to be private, but also provides a simple way to declare codice_13 and codice_14 methods. This is in keeping with the idea that in Ruby, one never directly accesses the internal members of a class from outside the class; rather, one passes a message to the class and receives a response.

See the Examples section below for samples of code demonstrating Ruby syntax.

The Ruby official distribution also includes codice_15, an interactive command-line interpreter that can be used to test code quickly. The following code fragment represents a sample session using codice_15:

The following examples can be run in a Ruby shell such as Interactive Ruby Shell, or saved in a file and run from the command line by typing codice_17.

Classic Hello world example:

Some basic Ruby code:

Input:

Conversions:

There are a variety of ways to define strings in Ruby.

The following assignments are equivalent:

Strings support variable interpolation:

The following assignments are equivalent and produce raw strings:

Constructing and using an array:

Constructing and using an [[associative array]] (in Ruby, called a "hash"):

If statement:

The two syntaxes for creating a code block:

A code block can be passed to a method as an optional block argument. Many built-in methods have such arguments:

Parameter-passing a block to be a [[Closure (computer science)|closure]]:

Creating an [[anonymous function]]:

Returning [[Closure (computer science)|closures]] from a method:

Yielding the flow of program control to a block that was provided at calling time:

Iterating over enumerations and arrays using blocks:

A method such as codice_18 can accept both a parameter and a block. The codice_18 method iterates over each member of a list, performing some function on it while retaining an aggregate. This is analogous to the codice_20 function in [[functional programming languages]]. For example:

On the first pass, the block receives 10 (the argument to inject) as codice_21, and 1 (the first element of the array) as codice_22. This returns 11, which then becomes codice_21 on the next pass. It is added to 3 to get 14, which is then added to 5 on the third pass, to finally return 19.

Using an enumeration and a block to square the numbers 1 to 10 (using a "range"):

Or invoke a method on each item (codice_24 is a synonym for codice_25):

The following code defines a class named codice_26. In addition to codice_27, the usual constructor to create new objects, it has two methods: one to override the codice_28 comparison operator (so codice_29 can sort by age) and the other to override the codice_30 method (so codice_31 can format its output). Here, codice_12 is an example of metaprogramming in Ruby: codice_33 defines getter and setter methods of instance variables, but codice_12 only getter methods. The last evaluated statement in a method is its return value, allowing the omission of an explicit codice_35 statement.

The preceding code prints three names in reverse age order:

codice_26 is a constant and is a reference to a codice_37 object.

In Ruby, classes are never closed: methods can always be added to an existing class. This applies to "all" classes, including the standard, built-in classes. All that is needed to do is open up a class definition for an existing class, and the new contents specified will be added to the existing contents. A simple example of adding a new method to the standard library's codice_38 class:

Adding methods to previously defined classes is often called [[monkey patch|monkey-patching]]. If performed recklessly, the practice can lead to both behavior collisions with subsequent unexpected results and code scalability problems.

Since Ruby 2.0 it has been possible to use refinements to reduce the potentially negative consequences of monkey-patching, by limiting the scope of the patch to particular areas of the code base.

An exception is raised with a codice_39 call:

An optional message can be added to the exception:

Exceptions can also be specified by the programmer:

Alternatively, an exception instance can be passed to the codice_39 method:

This last construct is useful when raising an instance of a custom exception class featuring a constructor that takes more than one argument:

Exceptions are handled by the codice_41 clause. Such a clause can catch exceptions that inherit from codice_42. Other flow control keywords that can be used when handling exceptions are codice_43 and codice_44:

It is a common mistake to attempt to catch all exceptions with a simple rescue clause. To catch all exceptions one must write:

Or catch particular exceptions:

It is also possible to specify that the exception object be made available to the handler clause:

Alternatively, the most recent exception is stored in the magic global codice_45.

Several exceptions can also be caught:

Ruby code can programmatically modify, at [[Run time (program lifecycle phase)|runtime]], aspects of its own structure that would be fixed in more rigid languages, such as class and method definitions. This sort of [[metaprogramming]] can be used to write more concise code and effectively extend the language.

For example, the following Ruby code generates new methods for the built-in codice_46 class, based on a list of colors. The methods wrap the contents of the string with an HTML tag styled with the respective color.

The generated methods could then be used like this:

To implement the equivalent in many other languages, the programmer would have to write each method (codice_47, codice_48, codice_49, etc.) separately.

Some other possible uses for Ruby metaprogramming include:

More sample Ruby code is available as algorithms in the following article:

The original Ruby [[interpreter (computer software)|interpreter]] is often referred to as the [[Ruby MRI|Matz's Ruby Interpreter]] or MRI. This implementation is written in C and uses its own Ruby-specific [[virtual machine]].

The standardized and retired Ruby 1.8 [[Ruby MRI|implementation]] was written in [[C (programming language)|C]], as a single-pass [[interpreted language]].

Starting with Ruby 1.9, and continuing with Ruby 2.x and above, the official Ruby interpreter has been [[YARV]] ("Yet Another Ruby VM"), and this implementation has superseded the slower virtual machine used in previous releases of MRI.

, there are a number of alternative implementations of Ruby, including [[JRuby]], [[Rubinius]], and [[mruby]]. Each takes a different approach, with JRuby and Rubinius providing [[just-in-time compilation]] and mruby also providing [[ahead-of-time compilation]].

Ruby has three major alternate implementations:

Other Ruby implementations include:

Other now defunct Ruby implementations were:

The maturity of Ruby implementations tends to be measured by their ability to run the [[Ruby on Rails]] (Rails) framework, because it is complex to implement and uses many Ruby-specific features. The point when a particular implementation achieves this goal is called "the Rails singularity". The reference implementation [[Ruby MRI|(MRI)]], [[JRuby]], and [[Rubinius]] are all able to run Rails unmodified in a production environment.

Matsumoto originally did Ruby development on the [[BSD|4.3BSD]]-based [[Sony NEWS|Sony NEWS-OS]] 3.x, but later migrated his work to [[SunOS]] 4.x, and finally to [[Linux]].

By 1999, Ruby was known to work across many different [[operating system]]s, including NEWS-OS, SunOS, [[AIX]], [[SVR4]], [[Solaris (operating system)|Solaris]], [[NEC]] [[UP-UX]], [[NeXTSTEP]], BSD, Linux, [[Classic Mac OS|Mac OS]], [[DOS]], [[Windows (operating system)|Windows]], and [[BeOS]].

Modern Ruby versions and implementations are available on many operating systems, such as Linux, BSD, Solaris, AIX, [[macOS]], Windows, [[Windows Phone]], [[Windows CE]], [[Symbian OS]], BeOS, and [[IBM i]].

[[RubyGems]] is Ruby's package manager. A Ruby package is called a "gem" and can easily be installed via the command line. Most gems are libraries, though a few exist that are applications, such as [[integrated development environment|IDEs]]. There are over 9,000 Ruby gems hosted on RubyGems.org.

Many new and existing Ruby libraries are hosted on [[GitHub]], a service that offers [[Revision control|version control]] repository hosting for [[Git (software)|Git]].

The Ruby Application Archive, which hosted applications, documentation, and libraries for Ruby programming, was maintained until 2013, when its function was transferred to RubyGems.[[Category:Ruby (programming language)| ]]
[[Category:Articles with example Ruby code]]
[[Category:Class-based programming languages]]
[[Category:Dynamic programming languages]]
[[Category:Dynamically typed programming languages]]
[[Category:Free software programmed in C]]
[[Category:ISO standards]]
[[Category:Object-oriented programming languages]]
[[Category:Programming languages created in 1995]]
[[Category:Programming languages with an ISO standard]]
[[Category:Scripting languages]]
[[Category:Software using the BSD license]]
[[Category:Text-oriented programming languages]]
[[Category:Free compilers and interpreters]]


What is the most abundant amino acid in the human body?

Glutamine (symbol Gln or Q) is an α-amino acid that is used in the biosynthesis of proteins. Its side chain is similar to that of glutamic acid, except the carboxylic acid group is replaced by an amide. It is classified as a charge-neutral, polar amino acid. It is non-essential and conditionally essential in humans, meaning the body can usually synthesize sufficient amounts of it, but in some instances of stress, the body's demand for glutamine increases, and glutamine must be obtained from the diet. It is encoded by the codons CAA and CAG.

Glutamine

In human blood, glutamine is the most abundant free amino acid.

The dietary sources of glutamine includes especially the protein-rich foods like beef, chicken, fish, dairy products, eggs, vegetables like beans, beets, cabbage, spinach, carrots, parsley, vegetable juices and also in wheat, papaya, Brussels sprouts, celery, kale and fermented foods like miso.

Glutamine plays a role in a variety of biochemical functions:

On the level of tissue, glutamine plays a role in maintaining the normal integrity of the intestinal mucosa., but randomised trials provide no evidence of any benefit of nutritional supplementation.

Glutamine is synthesized by the enzyme glutamine synthetase from glutamate and ammonia. The most relevant glutamine-producing tissue is the muscle mass, accounting for about 90% of all glutamine synthesized. Glutamine is also released, in small amounts, by the lungs and brain. Although the liver is capable of relevant glutamine synthesis, its role in glutamine metabolism is more regulatory than producing, since the liver takes up large amounts of glutamine derived from the gut.

The most eager consumers of glutamine are the cells of intestines, the kidney cells for the acid-base balance, activated immune cells, and many cancer cells.

Glutamine is the most abundant naturally occurring, nonessential amino acid in the human body, and one of the few amino acids that can directly cross the blood–brain barrier. Humans obtain glutamine through catabolism of proteins in foods they eat. In states where tissue is being built or repaired, like growth of babies, or healing from wounds or severe illness, glutamine becomes conditionally essential.

In 2017, the U.S. Food and Drug Administration (FDA) approved L-glutamine oral powder, marketed as Endari, to reduce severe complications of sickle cell disease in people aged 5 years and older with the disorder.

Glutamine is marketed as medical food and is prescribed when a medical professional believes a person in their care needs supplementary glutamine due to metabolic demands beyond what can be met by endogenous synthesis or diet.

Glutamine is safe in adults and in preterm infants. Although glutamine is metabolized to glutamate and ammonia, both of which have neurological effects, their concentrations are not increased much, and no adverse neurological effects were detected. The observed safe level for supplemental L-glutamine in normal healthy adults is 14 g/day.

Adverse effects of glutamine have been described for people receiving home parenteral nutrition and those with liver-function abnormalities.
Although glutamine has no effect on the proliferation of tumor cells, it is still possible that glutamine supplementation may be detrimental in some cancer types.

Ceasing glutamine supplementation in people adapted to very high consumption may initiate a withdrawal effect, raising the risk of health problems such as infections or impaired integrity of the intestine.

Glutamine can exist in either of two enantiomeric forms, -glutamine and -glutamine. The -form is found in nature. Glutamine contains an α-amino group which is in the protonated −NH form under biological conditions and a carboxylic acid group which is in the deprotonated −COO form, known as carboxylate, under physiological conditions.

Glutamine mouthwash may be useful to prevent oral mucositis in people undergoing chemotherapy but intravenous glutamine does not appear useful to prevent mucositis in the GI tract.

Glutamine supplementation was thought to have potential to reduce complications in people who are critically ill or who have had abdominal surgery but this was based on poor quality clinical trials. Supplementation does not appear to be useful in adults or children with Crohn's disease or inflammatory bowel disease, but clinical studies as of 2016 were underpowered. Supplementation does not appear to have an effect in infants with significant problems of the stomach or intestines.

Glutamine

Glutamine

Glutamate is a major constituent of a wide variety of proteins; consequently it is one of the most abundant amino acids in the human body. Under ordinary conditions enough is obtained from the diet that there is no need for any to be synthesized. Nevertheless, glutamate is formally classified as a non-essential amino acid, because it can be synthesized from alpha-Ketoglutaric acid, which is produced as part of the citric acid cycle by a series of reactions whose starting point is citrate. Glutamate cannot cross the blood-brain barrier unassisted, but it is actively transported into the nervous system by a high affinity transport system, which maintains its concentration in brain fluids at a fairly constant level.

Glutamate (neurotransmitter)

In neuroscience, glutamate refers to the anion of glutamic acid in its role as a neurotransmitter: a chemical that nerve cells use to send signals to other cells. It is by a wide margin the most abundant excitatory neurotransmitter in the vertebrate nervous system. It is used by every major excitatory function in the vertebrate brain, accounting in total for well over 90% of the synaptic connections in the human brain. It also serves as the primary neurotransmitter for some localized brain regions, such as cerebellum granule cells.

Biochemical receptors for glutamate fall into three major classes, known as AMPA receptors, NMDA receptors, and metabotropic glutamate receptors. A fourth class, known as kainate receptors, are similar in many respects to AMPA receptors, but much less abundant. Many synapses use multiple types of glutamate receptors. AMPA receptors are ionotropic receptors specialized for fast excitation: in many synapses they produce excitatory electrical responses in their targets a fraction of a millisecond after being stimulated. NMDA receptors are also ionotropic, but they differ from AMPA receptors in being permeable, when activated, to calcium. Their properties make them particularly important for learning and memory. Metabotropic receptors act through second messenger systems to create slow, sustained effects on their targets.

Because of its role in synaptic plasticity, glutamate is involved in cognitive functions such as learning and memory in the brain. The form of plasticity known as long-term potentiation takes place at glutamatergic synapses in the hippocampus, neocortex, and other parts of the brain. Glutamate works not only as a point-to-point transmitter, but also through spill-over synaptic crosstalk between synapses in which summation of glutamate released from a neighboring synapse creates extrasynaptic signaling/volume transmission. In addition, glutamate plays important roles in the regulation of growth cones and synaptogenesis during brain development.

Glutamate is synthesized in the central nervous system from glutamine as part of the glutamate-glutamine cycle by the enzyme glutaminase. This can occur in the presynaptic neuron or in neighboring glial cells.

Glutamate itself serves as metabolic precursor for the neurotransmitter GABA, via the action of the enzyme glutamate decarboxylase.

Glutamate exerts its effects by binding to and activating cell surface receptors. In mammals, four families of glutamate receptors have been identified, known as AMPA receptors, kainate receptors, NMDA receptors, and metabotropic glutamate receptors. The first three families are ionotropic, meaning that when activated they open membrane channels that allow ions to pass through. The metabotropic family are G protein-coupled receptors, meaning that they exert their effects via a complex second messenger system.

Glutamate transporters, EAAT and VGLUT, are found in neuronal and glial membranes. They rapidly remove glutamate from the extracellular space. In brain injury or disease, they often work in reverse, and excess glutamate can accumulate outside cells. This process causes calcium ions to enter cells via NMDA receptor channels, leading to neuronal damage and eventual cell death, and is called excitotoxicity. The mechanisms of cell death includeExcitotoxicity due to excessive glutamate release and impaired uptake occurs as part of the ischemic cascade and is associated with stroke, autism, some forms of intellectual disability, and diseases such as amyotrophic lateral sclerosis, lathyrism, and Alzheimer's disease. In contrast, decreased glutamate release is observed under conditions of classical phenylketonuria leading to developmental disruption of glutamate receptor expression.

Glutamic acid has been implicated in epileptic seizures. Microinjection of glutamic acid into neurons produces spontaneous depolarisations around one second apart, and this firing pattern is similar to what is known as paroxysmal depolarizing shift in epileptic attacks. This change in the resting membrane potential at seizure foci could cause spontaneous opening of voltage-activated calcium channels, leading to glutamic acid release and further depolarization.

Glutamate functions as a neurotransmitter in every type of animal that has a nervous system, including ctenophores (comb jellies), which branched off from other phyla at an early stage in evolution and lack the other neurotransmitters found ubiquitously among animals, including serotonin and acetylcholine. Rather, ctenophores have functionally distinct types of ionotropic glutamate receptors, such that activation of these receptors may trigger muscle contraction and other responses.

Sponges do not have a nervous system, but also make use of glutamate for cell-to-cell signalling. Sponges possess metabotropic glutamate receptors, and application of glutamate to a sponge can trigger a whole-body response that sponges use to rid themselves of contaminants. The genome of "Trichoplax", a primitive organism that also lacks a nervous system, contains numerous metabotropic glutamate receptors, but their function is not yet known.

In arthropods and nematodes, glutamate stimulates glutamate-gated chloride channels. The β subunits of the receptor respond with very high affinity to glutamate and glycine. Targeting these receptors has been the therapeutic goal of anthelmintic therapy using avermectins. Avermectins target the alpha subunit of glutamate-gated chloride channels with high affinity. These receptors have also been described in arthropods, such as "Drosophila melanogaster" and "Lepeophtheirus salmonis". Irreversible activation of these receptors with avermectins results in hyperpolarization at synapses and neuromuscular junctions resulting in flaccid paralysis and death of nematodes and arthropods.

The presence of glutamate in every part of the body as a building-block for protein made its special role in the nervous system difficult to recognize: its function as a neurotransmitter was not generally accepted until the 1970s, decades after the identification of acetylcholine, norepinephrine, and serotonin as neurotransmitters. The first suggestion that glutamate might function as a transmitter came from T. Hayoshi in 1952, who was motivated by the finding that injections of glutamate into the cerebral ventricles of dogs could cause them to have seizures.
Other support for this idea soon appeared, but the majority of physiologists were skeptical, for a variety of theoretical and empirical reasons. One of the most common reasons for skepticism was the universality of glutamate's excitatory effects in the central nervous system, which seemed inconsistent with the specificity expected of a neurotransmitter. Other reasons for skepticism included a lack of known antagonists and the absence of a known mechanism for inactivation. A series of discoveries during the 1970s resolved most of these doubts, and by 1980 the compelling nature of the evidence was almost universally recognized.


Who is the actress for Caroline on Runaways?

Virginia Elizabeth Gardner (born April 18, 1995) is an American actress who is known for playing Karolina Dean in the Hulu original series "Marvel's Runaways" (2017) and Vicky in David Gordon Green's horror film "Halloween" (2018).

Virginia Gardner

Gardner was born in Sacramento, California. She attended Sacramento Country Day School from kindergarten to eighth grade. She took part in many of her middle school's productions. Brian Frishman, head of the drama department, directed Gardner from sixth to eighth grade. In 2011, she did online schooling when she moved to Los Angeles, but then chose to take the California High School Proficiency Exam when she was allowed to. She took the test in October 2011 and found out she passed the following month.

Gardner initially lived with her mother to pursue acting full-time. Gardner lived with her mother for the first year; however, once she started to be more successful and able to handle herself, she moved into her own apartment and began to live on her own. After appearing on the Disney Channel series "Lab Rats", she took a year off from acting to work on modeling. When she became absorbed in modeling, she was going to stop acting, but then heard about the audition for "Glee". She has modeled for Kohl's, Love Culture, HP, Hollister, LF, and Famous Footwear. In 2015, Gardner starred in the film "Project Almanac" as Christina Raskin, the main character's younger sister. In February 2017, it was announced that Gardner would star as Karolina Dean in Marvel's "Runaways", a Hulu original series. In January 2018, it was announced that Gardner would star as Vicky in "Halloween" (2018), a sequel to the 1978 film of the same name, in which Jamie Lee Curtis reprises her role as Laurie Strode. Vicky becomes a victim of the Michael Myers character, but sacrifices herself to protect a child.

Karolina Dean is portrayed by Virginia Gardner in the Hulu television series "Runaways" which is set in the Marvel Cinematic Universe. This version of the character is half human and half alien.

Karolina Dean

Karolina Dean ( ), also briefly known as Lucy in the Sky, or L.S.D., is a fictional character, a superhero appearing in American comic books published by Marvel Comics. The character first appeared in the series "Runaways". Like every member of the original Runaways, she is the daughter of evil super-powered criminals; while searching through her parents' home, Karolina inadvertently discovers that her parents were Majesdanian invaders. Majesdanians are an alien race that absorbs solar energy and re-radiates it in the form of the colors of the rainbow. She is often called "Kar," “Karo,” or "K" for short, and is known for her free spirit and kind nature.

Karolina is the only extraterrestrial in the group, except for a period of time when her Skrull fiancée, Xavin, becomes part of the team. "Runaways" creator Brian K. Vaughan played a significant role in the character's subsequent development as well as artist/writer Adrian Alphona, both of whom spent most of the first volume of the series hinting that Karolina was romantically attracted to fellow member Nico Minoru. By "Runaways"'s fourth relaunch, Karolina's storyline picks up with her relationship with Lightspeed of Power Pack referenced in "Avengers Academy".

Karolina Dean was created by author Brian K. Vaughan & artist Adrian Alphona and debuted in "Runaways" #1.

Karolina is the daughter of renowned Hollywood actors Frank and Leslie Dean and is the only older Runaway who didn't witness their parents murder an innocent girl as a sacrifice. Karolina denies the entire situation primarily, but finally believes the group soon after discovering she is an alien. The kids decide to go for a massive ransack, and leave home; before leaving for good, they decide to put their parents to justice by collecting certain evidence from their homes. When arriving at the Dean mansion, they find Karolina's parent's last will and testament; Karolina is given a piece of paper with the circular "no symbol" covering the Caduceus. Alex convinces her to remove her medic alert bracelet because it is emblazoned with the symbol. Karolina angrily concedes, thinking that she only wears the bracelet because she's allergic to penicillin, and her skin immediately glows with a fluid, rainbow-like light. Remembering something they heard from the Pride's sacrifice, the group assumes Karolina is an alien and the bracelet is an anchor to hide her powers; Leslie Dean later confirms these theories for Karolina. After escaping their parents, Karolina takes the name Lucy in the Sky, a reference to the song "Lucy in the Sky with Diamonds".

Early in the series, Karolina constantly struggled with her alien heritage, feeling that she is a "freak" amongst the group, the only one who needs to actively hide her true form. Another insecurity was of her speculated homosexuality. Her insecurities even prompt Karolina to offer her life to the vampire Topher, as Karolina expresses little desire to live. After her first near-death experience at the hands of Alex Wilder, Karolina overcomes her death wish and helps the Runaways escape the rampaging Gibborim as the Pride fight their former benefactors. After the Pride's defeat, Karolina is sent to live with foster parents, but she organizes a secret reunion for the Runaways, after which they run away again, this time to the Pride's old lair beneath the La Brea Tar Pits. Karolina is portrayed as having a wide, free spirit, notably when she discovers she can fly. But she is also shown as being quite sensitive, often crying at her pain and misfortune, as well as the pain and misfortune of others.

In the early issues of "Runaways", volume 2, Karolina fights under the command of de facto leader Nico. Karolina expresses more comfort with being an extraterrestrial and makes strong hints at being a lesbian, especially as she stops to compliment Julie Power on her beauty during a battle with Excelsior over the custody of Victor Mancha and later even agrees to go on a date with her following a joint Avengers Academy/Runaways mission (and would eventually become romantically involved). Soon after Victor joins the team, Karolina "comes out" to Nico with an attempted kiss, which Nico rejects outright. Karolina's "outcast" insecurities resurface when her Skrull fiancée Xavin comes to Earth in search for her. Unbeknownst to her, Karolina's parents arranged Xavin's and Karolina's marriage as part of a peaceweaving effort between the Skrull and Majesdanian (her species) homeworlds. Karolina leaves with Xavin, much to Nico's distress.

While on her home planet Majesdane, Karolina learns to control the shift between her Majesdanian and humanoid forms and how to further control her solar powers. However, the wedding does not go as planned and the couple flees towards Earth as their homeworlds reignite the old war. They crash land near the Hostel and return in time to assist in the rescue of Molly Hayes. Karolina has a dream of her parents tearing her apart. Karolina remains with the team and Xavin becomes accepted as a member after Gertrude Yorkes' death, and they both join the Runaways in defeating the Gibborim for good. When the Runaways are accidentally displaced in 1907, Karolina meets Klara Prast, and convinces everyone to accept her on the team.

In "S.W.O.R.D." #2, Karolina is one of the aliens kidnapped by Henry Gyrich in his "aliens go home" policy. He uses pheromones to target Karolina's Majesdanian physiology and leads her away from the Runaways and kidnaps her without difficulty. She was eventually freed along with the other aliens. She assists in saving the Earth from a fleet of murder-happy aliens. Abigail Brand, now the sole head of S.W.O.R.D., returns all the aliens to Earth, reassuring them they will have their freedom and they are each owed one favor. In "Avengers Arena", Karolina and Molly sought out Hank Pym for help when Nico and Chase go missing. Karolina dismissed Molly's concerns that somebody took their friends instead she believed they ran off to be together. Karolina later appears in the pages of "Avengers Undercover" where she and Molly visit Nico and Chase in the S.H.I.E.L.D. detention center after Hazmat allegedly killed Arcade. Karolina entered a relationship with Julie Power of Power Pack.

After the Runaways disbanded for some time, Karolina has moved on to a happy new life in college and left behind her anxieties over her old life with the help of therapy; thus, declined the invitation to reunite even with the return of undead Gert. Karolina reasoned she had grown up and changed from their time as scared kids on the run. She also felt it didn't make sense for them to get back together because they were never a team, like the Avengers, or had a mission, other than staying alive and not becoming their parents. Nico agreed with Karolina's assessment, but it still left her riddled with guilt. Karolina dropped by Nico's apartment to reconsider the reunion when Nico attempted to kiss Karolina but is rejected due to having a girlfriend and dismissed it as Nico's habit of seeking comfort at times of stress. The Runaways banded together to rescue Gert and Molly from Molly's mad scientist grandmother's house. Karolina avoided hurting Molly's grandmother and her genetically engineered creations; however, once Nico was struck by a telepathic attack, Karolina blasted the house and put an end to it. Battered but finding solace together as a makeshift family, they all decided to go home.

The Runaways resettled into their old hideout, the Hostel. Karolina is fitting in like she never left like her friendship with Nico hasn't missed a beat, but she struggles to give equal attention to her classes and girlfriend. When Julie's eagerly awaited visit is interrupted by Dr. Doom's attack on the hostel, Karolina and Julie don't see eye-to-eye on how Runaways improvise-styled battle plan and their functionality as a super-hero family team works. Julie expressed frustration of Karolina not opening up in their relationship, especially about her past that's now her present. To drown her sorrows in sugar over Karolina ignoring her once again, Julie unknowingly ate an enchanted cupcake that transformed her back to a thirteen year old forever. The Runaways eventually reverse the spell, but Julie still broke up with Karolina as she felt Karolina placed her membership in the Runaways on a higher priority. While Nico and Karolina bonded over lost loves, Karolina admitted she had been neglecting Julie which, perhaps, made their breakup inevitable. Following the break-up, Karolina invited Nico to attend her parents’ legitimate children's charity ball with her. While there, Nico confessed her feelings asking Karolina for a second chance. Karolina was surprised and scared. After some hesitation that left Karolina feeling rejected again, Nico finally seized her chance and the two kissed, beginning a relationship.

Karolina gets along well with the other Runaways, and the only time she had ever got into an argument with them was after they questioned her about Xavin's gender. She has an older-sister type relationship with Molly, but a caring relationship with both Chase and Victor, whom she had both comforted after they lost loved ones.

It was subtly hinted throughout the first volume of "Runaways" that Karolina had harbored a longtime crush on Nico. Much later, Karolina attempted to kiss Nico, but was rejected. Karolina then came out to Nico as a lesbian, admitting her feelings for Nico. After deciding to leave Earth to marry Xavin, Karolina left her medical alert bracelet with Nico as a token of remembrance. When Karolina later returned to Earth, she accidentally confessed to Xavin (who had taken on the form of Nico) that she was still in love with Nico. Despite this, Karolina remained staunch in her devotion to Xavin, and thus her feelings for and attraction to Nico occasionally put a strain on their friendship.

When the Runaways re-banded some time later, Nico made possible romantic overtures towards Karolina, ultimately attempting to kiss her. However, Karolina rejected Nico out of faithfulness to Julie and dismissed it as Nico's habit of seeking comfort in times of stress. Following Julie and Karolina's break-up, Karolina invited Nico to attend her parents’ legitimate foundation's a charity ball with her. While there, Karolina's usual nervousness was replaced by newfound confidence because of Nico's support as she's felt Nico had “always seen the real” her. Nico confessed she was confused about herself for so long she couldn't see her clearly. Nico knows who and what she wants now and asks Karolina for a second chance. Karolina was surprised and scared, which exacerbated her old feelings of rejection when Nico pulled away. But Nico seized her chance and the two kissed, beginning a relationship.

Xavin came to Earth to marry Karolina, revealing that their parents had arranged a marriage between the two of them in order to keep Earth safe from Skrull attacks. Karolina initially rejected Xavin; Xavin attempted to persuade her, explaining that the marriage would be part of a peace treaty. Karolina still refused, stating that it would be a "lie" for her to marry a man. Xavin then revealed that Skrulls had the ability to shapeshift into different genders, prompting Karolina to decide to accept the marriage proposal. However, they were later unable to get married when war broke out again between the Skrulls and Majesdanians. They escaped to Earth and re-joined the Runaways. Throughout their relationship, Karolina apparently fully accepted Xavin's continued changing between male and female appearances. However, she secretly expressed confusion and doubts over Xavin's true gender. However, during an argument, Xavin subconsciously reverted to female human form, which pleased Karolina. Their relationship ended when Xavin left Earth with a remaining group of Majesdanians, sacrificing themself for Karolina.

Karolina flirted with and later began dating Julie Power, after a trip to Avengers Academy; this resulted in long-term relationship. Julie attempted to convince Karolina to move to New York so they could be together full-time after the past year apart, though Karolina was resistant to this. After visiting Karolina in Los Angeles, Julie broke up with her, believing that she and Karolina were too incompatible and that Karolina's first priority would always be to the Runaways.

Like all Majesdanians, Karolina's natural form is luminous, iridescent, and visually fluid, often depicted with waves of rainbow-like light floating off her body (Chase described her as "a burning painting") though body structure is essentially humanoid. Originally, Karolina required a custom made medic alert bracelet constructed of an unspecified alien metal to revert to humanoid form. However, after spending many months on Majesdane, Karolina learned to control the change and can make it at will. In her Majesdanian form, Karolina is able to manipulate solar energy absorbed by her body to generate large concussive blasts, fine laser-like beams and force fields capable of stopping cave-ins, gunfire and explosions. Like her parents, Karolina learned the ability to bind people, binding a New Pride in a colorful sphere. Karolina's Majesdanian form also grants her the ability to fly. During an encounter with the vampire Topher, it is revealed that Karolina's blood also harbors solar energy-based properties, because drinking her blood caused Topher to combust.

The drawback to Karolina's powers is that they have a finite charge. If she is in her Majesdanian form too long or exerts her powers too much, her glow will start to fade and revert her to human form until she uses the sun's rays to recharge. The only time she entirely lost her powers was when the Runaways battled the Gibborim to prevent Chase from sacrificing himself. Leslie Dean stated early in the series that Majesdanians' abilities do not affect one another.

In Brian K. Vaughan's original pitch for the series, Karolina Dean was originally called Leslie. This name would eventually be given to the character's mother. Her parents were originally real estate agents, rather than famous actors. Molly's parents were meant to be famous, but were redesigned as doctors instead.

Karolina's Majesdanian form has been colored in two distinct styles. Brian Reber, the first colorist of "Runaways", colored Karolina with many different colors of the visible spectrum from panel to panel. Christina Strain, the second colorist for "Runaways", colors Karolina in lighter tones, using primarily blue, yellow, and pink with a glitter-like effect.

Karolina Dean is mentioned as being a "go-to" girl for the Wolfpack. However, this is a ploy to capture the Wolfpack. It is mentioned, however, that the Pride rule Southern California.

A zombie Karolina Dean is attacking Kitty Pryde and her son Peter in "Marvel Zombies Halloween". She is stopped by Mephisto.

Karolina Dean appears in the Hulu television series, "Runaways" portrayed by Virginia Gardner. Karolina's power dampening bracelet is still intact, but her fear of removing it comes from her mother's religious-like background. She is mocked at school by her peers who view her as being brainwashed by her cult-like religion called the Church of Gibborim founded by her grandfather and a benefactor named Jonah. Throughout the course of the first season, she slowly learns more about her true form and supernatural abilities. She later kisses Nico, revealing her feelings, and the two then begin a relationship. In season two, she learns and embraces her dual identity of human and alien. Instead of being Majesdanian, she is half-human and half-Gibborim from a family of exiled Royal Magistrates.

Karolina Dean


Do all female mammals menstruate?

Menstruation in mammals is the shedding of the uterine lining (endometrium). It occurs on a regular basis in uninseminated sexually reproductive-age females of certain mammal species.

Menstruation (mammal)

Although there is some disagreement in definitions between sources, menstruation is generally considered to be limited to primates. Overt menstruation (where there is bleeding from the uterus through the vagina) is found primarily in humans and close relatives such as chimpanzees. It is common in simians (Old World monkeys, and apes), but completely lacking in strepsirrhine primates and possibly weakly present in tarsiers. Beyond primates, it is known only in bats and the elephant shrew.

Females of other species of placental mammal undergo estrous cycles, in which the endometrium is completely reabsorbed by the animal (covert menstruation) at the end of its reproductive cycle. Many zoologists regard this as different from a "true" menstrual cycle. Female domestic animals used for breeding —for example dogs, pigs, cattle, or horses— are monitored for physical signs of an estrous cycle period, which indicates that the animal is ready for insemination.

Females of most mammal species advertise fertility to males with visual behavioral cues, pheromones, or both. This period of advertised fertility is known as "oestrus", "estrus" or "heat". In species that experience estrus, females are generally only receptive to copulation while they are in heat (dolphins are an exception). In the estrous cycles of most placental mammals, if no fertilization takes place, the uterus reabsorbs the endometrium. This breakdown of the endometrium without vaginal discharge is sometimes called "covert menstruation". Overt menstruation (where there is blood flow from the vagina) occurs primarily in humans and close evolutionary relatives such as chimpanzees. Some species, such as domestic dogs, experience small amounts of vaginal bleeding while approaching heat; this discharge has a different physiologic cause than menstruation.

A few mammals do not experience obvious, visible signs of fertility (concealed ovulation). In humans, while women can learn to recognize their own level of fertility (fertility awareness), whether men can detect fertility in women is debated; recent studies have given conflicting results.

Orangutans also lack visible signs of impending ovulation. Also, it has been said that the extended estrus period of the bonobo (reproductive-age females are in heat for 75% of their menstrual cycle) has a similar effect to the lack of a "heat" in human females.

Most female mammals have an estrous cycle, yet only ten primates species, four bats species, the elephant shrew, and the spiny mouse have a menstrual cycle. The relatedness of these groups suggests that four distinct evolutionary events have caused menstruation to arise.

Recent reviews suggest that menstruation itself is not an evolved, adaptive trait. Rather, it is an inherent consequence of spontaneous decidualization evolving as a derived trait from non-spontaneous decidualization. Spontaneous decidualization allows for more maternal control in the maternal-fetal conflict by increasing selectivity over the implanted embryo.

All female placental mammals have a uterine lining that builds up when the animal is fertile, but is dismantled (menstruated) when the animal is infertile. Some anthropologists have questioned the energy cost of rebuilding the endometrium every fertility cycle. However, anthropologist Beverly Strassmann has proposed that the energy savings of not having to "continuously" maintain the uterine lining more than offsets energy cost of having to rebuild the lining in the next fertility cycle, even in species such as humans where much of the lining is lost through bleeding (overt menstruation) rather than reabsorbed (covert menstruation). However, even in humans, much of it is re-absorbed.

Many have questioned the evolution of overt menstruation in humans and related species, speculating on what advantage there could be to losing blood associated with dismantling the endometrium rather than absorbing it, as most mammals do.
The female will ovulate spontaneously and be receptive to the male to be bred (express estrus) at regular biologically defined intervals. The female is receptive to males only while experiencing estrus.

For breeding livestock, there are a number of advantages to be gained by finding methods to induce ovulation on a planned schedule, and thus synchronize the estrus cycle between many female animals. If animals can be bred on the same schedule, it increases convenience for the livestock owner, since the young animals will be at the same stage of development. Also, if artificial insemination (AI) is used for breeding, the AI technician's time can be used more efficiently, by breeding several females at the same time. In order to induce estrus, a variety of techniques have been tried in recent years, involving different ways of injecting or feeding hormones to livestock. They are costly, and have variable success rates.

Average length (days) of estrus and estrous cycles:

Menstruation (mammal)

Menstruation

Menstruation, also known as a period or monthly, is the regular discharge of blood and mucosal tissue (known as menses) from the inner lining of the uterus through the vagina. The first period usually begins between twelve and fifteen years of age, a point in time known as menarche. However, periods may occasionally start as young as eight years old and still be considered normal. The average age of the first period is generally later in the developing world, and earlier in the developed world. The typical length of time between the first day of one period and the first day of the next is 21 to 45 days in young women, and 21 to 31 days in adults (an average of 28 days). Bleeding usually lasts around 2 to 7 days. Menstruation stops occurring after menopause, which usually occurs between 45 and 55 years of age. Periods also stop during pregnancy and typically do not resume during the initial months of breastfeeding.
Up to 80% of women report having some symptoms prior to menstruation. Common signs and symptoms include acne, tender breasts, bloating, feeling tired, irritability, and mood changes. These may interfere with normal life, therefore qualifying as premenstrual syndrome, in 20 to 30% of women. In 3 to 8%, symptoms are severe.
A lack of periods, known as amenorrhea, is when periods do not occur by age 15 or have not occurred in 90 days. Other problems with the menstrual cycle include painful periods and abnormal bleeding such as bleeding between periods or heavy bleeding. Menstruation in other animals occur in primates (apes and monkeys).
The menstrual cycle occurs due to the rise and fall of hormones. This cycle results in the thickening of the lining of the uterus, and the growth of an egg, (which is required for pregnancy). The egg is released from an ovary around day fourteen in the cycle; the thickened lining of the uterus provides nutrients to an embryo after implantation. If pregnancy does not occur, the lining is released in what is known as menstruation.

The first menstrual period occurs after the onset of pubertal growth, and is called menarche. The average age of menarche is 12 to 15. However, it may start as early as eight. The average age of the first period is generally later in the developing world, and earlier in the developed world. The average age of menarche has changed little in the United States since the 1950s.

Menstruation is the most visible phase of the menstrual cycle and its beginning is used as the marker between cycles. The first day of menstrual bleeding is the date used for the last menstrual period (LMP). The typical length of time between the first day of one period and the first day of the next is 21 to 45 days in young women, and 21 to 31 days in adults (an average of 28 days).

Perimenopause is when fertility in a female declines, and menstruation occurs less regularly in the years leading up to the final menstrual period, when a female stops menstruating completely and is no longer fertile. The medical definition of menopause is one year without a period and typically occurs between 45 and 55 in Western countries.

During pregnancy and for some time after childbirth, menstruation does not occur. The average length of postpartum amenorrhoea is longer when breastfeeding; this is termed lactational amenorrhoea.

In most women, various physical changes are brought about by fluctuations in hormone levels during the menstrual cycle. This includes muscle contractions of the uterus (menstrual cramping) that can precede or accompany menstruation. Some may notice water retention, changes in sex drive, fatigue, breast tenderness, or nausea. Breast swelling and discomfort may be caused by water retention during menstruation. Usually, such sensations are mild, and some females notice very few physical changes associated with menstruation. A healthy diet, reduced consumption of salt, caffeine and alcohol, and regular exercise may be effective for women in controlling some symptoms. Severe symptoms that disrupt daily activities and functioning may be diagnosed as premenstrual dysphoric disorder. Symptoms before menstruation are known as premenstrual molimina.

Many women experience painful cramps, also known as dysmenorrhea, during menstruation. Pain results from ischemia and muscle contractions. Spiral arteries in the secretory endometrium constrict, resulting in ischemia to the secretory endometrium. This allows the uterine lining to slough off. The myometrium contracts spasmodically in order to push the menstrual fluid through the cervix and out of the vagina. The contractions are mediated by a release of prostaglandins.

Painful menstrual cramps that result from an excess of prostaglandin release are referred to as primary dysmenorrhea. Primary dysmenorrhea usually begins within a year or two of menarche, typically with the onset of ovulatory cycles. Treatments that target the mechanism of pain include non-steroidal anti-inflammatory drugs (NSAIDs) and hormonal contraceptives. NSAIDs inhibit prostaglandin production. With long-term treatment, hormonal birth control reduces the amount of uterine fluid/tissue expelled from the uterus. Thus resulting in shorter, less painful menstruation. These drugs are typically more effective than treatments that do not target the source of the pain (e.g. acetaminophen). Risk factors for primary dysmenorrhea include: early age at menarche, long or heavy menstrual periods, smoking, and a family history of dysmenorrhea. Regular physical activity may limit the severity of uterine cramps.

For many women, primary dysmenorrhea gradually subsides in late second generation. Pregnancy has also been demonstrated to lessen the severity of dysmenorrhea, when menstruation resumes. However, dysmenorrhea can continue until menopause. 5–15% of women with dysmenorrhea experience symptoms severe enough to interfere with daily activities.

Secondary dysmenorrhea is the diagnosis given when menstruation pain is a secondary cause to another disorder. Conditions causing secondary dysmenorrhea include endometriosis, uterine fibroids, and uterine adenomyosis. Rarely, congenital malformations, intrauterine devices, certain cancers, and pelvic infections cause secondary dysmenorrhea. Symptoms include pain spreading to hips, lower back and thighs, nausea, and frequent diarrhea or constipation. If the pain occurs between menstrual periods, lasts longer than the first few days of the period, or is not adequately relieved by the use of non-steroidal anti-inflammatory drugs (NSAIDs) or hormonal contraceptives, women should be evaluated for secondary causes of dysmenorrhea.

When severe pelvic pain and bleeding suddenly occur or worsen during a cycle, the woman or girl should be evaluated for ectopic pregnancy and spontaneous abortion. This evaluation begins with a pregnancy test and should be done as soon as unusual pain begins, because ectopic pregnancies can be life‑threatening.

In some cases, stronger physical and emotional or psychological sensations may interfere with normal activities, and include menstrual pain (dysmenorrhea), migraine headaches, and depression. Dysmenorrhea, or severe uterine pain, is particularly common for young females (one study found that 67.2% of girls aged 13–19 have it).

The medications in the non-steroidal anti-inflammatory drugs (NSAIDs) class are commonly used to relieve menstrual cramps. Some herbs are also claimed to help.

Some women experience emotional disturbances starting one or two weeks before their period, and stopping soon after the period has started. Symptoms may include mental tension, irritability, mood swings, and crying spells. Problems with concentration and memory may occur. There may also be depression or anxiety.

This is part of premenstrual syndrome (PMS) and is estimated to occur in 20 to 30% of women. In 3 to 8% it is severe.

More severe symptoms of anxiety or depression may be signs of premenstrual dysphoric disorder (PMDD). Rarely, in individuals who are susceptible, menstruation may be a trigger for menstrual psychosis.

Extreme psychological stress can also result in periods stopping.

The average volume of menstrual fluid during a monthly menstrual period is 35 milliliters (2.4 tablespoons of menstrual fluid) with 10–80 milliliters (1–6 tablespoons of menstrual fluid) considered typical. Menstrual fluid is the correct name for the flow, although many people prefer to refer to it as menstrual blood. Menstrual fluid contains some blood, as well as cervical mucus, vaginal secretions, and endometrial tissue. Menstrual fluid is reddish-brown, a slightly darker color than venous blood.

About half of menstrual fluid is blood. This blood contains sodium, calcium, phosphate, iron, and chloride, the extent of which depends on the woman. As well as blood, the fluid consists of cervical mucus, vaginal secretions, and endometrial tissue. Vaginal fluids in menses mainly contribute water, common electrolytes, organ moieties, and at least 14 proteins, including glycoproteins.

Many mature females notice blood clots during menstruation. These appear as clumps of blood that may look like tissue. If there are questions (for example, was there a miscarriage?), examination under a microscope can confirm if it was endometrial tissue or pregnancy tissue (products of conception) that was shed. Sometimes menstrual clots or shed endometrial tissue is incorrectly thought to indicate an early-term miscarriage of an embryo. An enzyme called plasmin – contained in the endometrium – tends to inhibit the blood from clotting.

The amount of iron lost in menstrual fluid is relatively small for most women. In one study, premenopausal women who exhibited symptoms of iron deficiency were given endoscopies. 86% of them actually had gastrointestinal disease and were at risk of being misdiagnosed simply because they were menstruating. Heavy menstrual bleeding, occurring monthly, can result in anemia.

There is a wide spectrum of differences in how women experience menstruation. There are several ways that someone's menstrual cycle can differ from the norm, any of which should be discussed with a doctor to identify the underlying cause:
There is a movement among gynecologists to discard the terms noted above, which although they are widely used, do not have precise definitions. Many now argue to describe menstruation in simple terminology, including:

Dysfunctional uterine bleeding is a hormonally caused bleeding abnormality. Dysfunctional uterine bleeding typically occurs in premenopausal women who do not ovulate normally (i.e. are anovulatory). All these bleeding abnormalities need medical attention; they may indicate hormone imbalances, uterine fibroids, or other problems. As pregnant women may bleed, a pregnancy test forms part of the evaluation of abnormal bleeding.

Women who had undergone female genital mutilation (particularly type III- infibulation) a practice common in parts of Africa, may experience menstrual problems, such as slow and painful menstruation, that is caused by the near-complete sealing off of the vagina.

Premature or delayed menarche should be investigated if menarche begins before 9 years, if menarche has not begun by age 15, if there is no breast development by age 13, or if there is no period by 3 years after the onset of breast development.

Sexual intercourse during menstruation does not cause damage in and of itself, but the woman's body is more vulnerable during this time. Vaginal pH is higher and thus less acidic than normal, the cervix is lower in its position, the cervical opening is more dilated, and the uterine endometrial lining is absent, thus allowing organisms direct access to the bloodstream through the numerous blood vessels that nourish the uterus. All these conditions increase the chance of infection during menstruation.

Hormonal contraception affects the frequency, duration, severity, volume, and regularity of menstruation and menstrual symptoms.

The most common form of hormonal contraception is the combined birth control pill, which contains both estrogen and progestogen. It is typically taken in 28-day cycles, 21 hormonal pills with either a 7-day break from pills, or 7 placebo pills during which the woman menstruates. Although the primary function of the pill is to prevent pregnancy, it may be used to treat some menstrual symptoms and syndromes which affect menstruation, such as polycystic ovary syndrome (PCOS), endometriosis, adenomyosis, amenorrhea, menstrual cramps, menstrual migraines, menorrhagia (excessive menstrual bleeding), menstruation-related or fibroid-related anemia and dysmenorrhea (painful menstruation). Using the combined birth control pill, it is also possible for a woman to delay or completely eliminate menstrual periods, a practice called menstrual suppression. Some women do this simply for convenience in the short-term, while others prefer to eliminate periods altogether when possible. This can be done either by skipping the placebo pills, or using an extended cycle combined oral contraceptive pill, which were first marketed in the U.S. in the early 2000s.

Injections such as depo-provera became available in the 1960s. When using progestogen implants, menstruation may be reduced to 3 or 4 menstrual periods per year.

Progestogen-only contraceptive pills (sometimes called the'mini pill') are taken continuously without a 7-day span of using placebo pills, and therefore menstrual periods are less likely to occur than with the combined pill with placebo pills. However, disturbance of the menstrual cycle is common with the mini-pill; 1/3-1/2 of women taking it will experience prolonged periods, and up to 70% experience break-through bleeding (metrorrhagia). Irregular and prolonged bleeding is the most common reason that women discontinue using the mini pill.

When the first birth control pill was being developed, the researchers were aware that they could use the contraceptive to space menstrual periods up to 90 days apart, but they settled on a 28-day cycle that would mimic a natural menstrual cycle and produce monthly periods. The intention behind this decision was the hope of the inventor, John Rock, to win approval for his invention from the Roman Catholic Church. That attempt failed, but the 28-day cycle remained the standard when the pill became available to the public.

There is debate among medical researchers about the potential long-term impacts of these practices upon female health. Some researchers point to the fact that historically, females have had far fewer menstrual periods throughout their lifetimes, a result of shorter life expectancies, as well as a greater length of time spent pregnant or breast-feeding, which reduced the number of periods experienced by females. These researchers believe that the higher number of menstrual periods by females in modern societies may have a negative impact upon their health. On the other hand, some researchers believe there is a greater potential for negative impacts from exposing females perhaps unnecessarily to regular low doses of synthetic hormones over their reproductive years.

Breastfeeding causes negative feedback to occur on pulse secretion of gonadotropin-releasing hormone (GnRH) and luteinizing hormone (LH). Depending on the strength of the negative feedback, breastfeeding women may experience complete suppression of follicular development, follicular development but no ovulation, or normal menstrual cycles may resume. Suppression of ovulation is more likely when suckling occurs more frequently. The production of prolactin in response to suckling is important to maintaining lactational amenorrhea. On average, women who are fully breastfeeding whose infants suckle frequently experience a return of menstruation at fourteen and a half months postpartum. There is a wide range of response among individual breastfeeding women, however, with some experiencing return of menstruation at two months and others remaining amenorrheic for up to 42 months postpartum.

Menstruation is managed by menstruating women to avoid damage to clothing or to accord with norms of public life. Menstrual management practices range from medical suppression of menstruation, through wearing special garments or other items, washing or avoidance of washing, disposal and laundry of stained materials, to separation of menstruators to particular places or activities.

Menstrual products (also called "feminine hygiene" products) are made to absorb or catch menstrual blood. A number of different products are available - some are disposable, some are reusable. Where women can afford it, items used to absorb or catch menses are usually commercially manufactured products.

There are disposable products:

Reusable products include:

In developing countries, many poor women cannot afford commercial feminine hygiene products. Instead, they use materials found in the environment or other improvised materials. Absorption materials that may be used by women who cannot afford anything else include: sand, ash, small hole in earth, cloth, whole leaf, leaf fibre (such as water hyacinth, banana, papyrus, cotton fibre), paper (toilet paper, re-used newspaper, pulped and dried paper), animal pelt e.g. goat skin, double layer of underwear, skirt or sari.

Many religions have menstruation-related traditions, for example: Islam prohibits sexual contact with women during menstruation in the 2nd chapter of the Quran. Some scholars argue that menstruating women are in a state in which they are unable to maintain wudhu, and are therefore prohibited from touching the Arabic version of the Qur'an. Other biological and involuntary functions such as vomiting, bleeding, sexual intercourse, and going to the bathroom also invalidate one's wudhu. In Judaism, a woman during menstruation is called Niddah and may be banned from certain actions. For example, the Jewish Torah prohibits sexual intercourse with a menstruating woman. In Hinduism, menstruating women are traditionally considered ritually impure and given rules to follow. During menstruation, women are not allowed to “enter the kitchen and temples", wear flowers, have sex, touch other males or females.” Western civilization, which has been predominantly Christian, has a history of menstrual taboos.

Menstruation education is frequently taught in combination with sex education at school in Western countries, although girls may prefer their mothers to be the primary source of information about menstruation and puberty. Information about menstruation is often shared among friends and peers, which may promote a more positive outlook on puberty. The quality of menstrual education in a society determines the accuracy of people's understanding of the process. In many Western countries where menstruation is a taboo subject, girls tend to conceal the fact that they may be menstruating and struggle to ensure that they give no sign of menstruation. Effective educational programs are essential to providing children and adolescents with clear and accurate information about menstruation. Schools can be an appropriate place for menstrual education to take place. Programs led by peers or third-party agencies are another option.

Some anthropologists have questioned the energy cost of rebuilding the endometrium every fertility cycle. It has proposed that the energy savings of not having to continuously maintain the uterine lining more than offsets energy cost of having to rebuild the lining in the next fertility cycle, even in species such as humans where much of the lining is lost through bleeding (overt menstruation) rather than reabsorbed (covert menstruation).

Many have questioned the evolution of overt menstruation in humans and related species, speculating on what advantage there could be to losing blood associated with dismantling the endometrium, rather than absorbing it, as most mammals do. Humans do, in fact, reabsorb about two-thirds of the endometrium each cycle. Some work asserts that overt menstruation occurs not because it is beneficial in itself. Rather, the fetal development of these species requires a more developed endometrium, one which is too thick to reabsorb completely. There is a correlation between species that have overt menstruation to those that have a large uterus relative to the adult female body size.

The grandmother hypothesis is a hypothesis to explain the existence of menopause in human life history by identifying the adaptive value of extended kin networking.

Beginning in 1971, some research suggested that menstrual cycles of cohabiting human females became synchronized (menstrual synchrony). However, there is currently significant dispute as to whether menstrual synchrony exists. A 2013 review concluded that menstrual synchrony likely does not exist.