Can someone explain the following code to me?
It's string interpolation. "#{email} (#{admin? ? "Admin" : "User"})"
is equivalent to
email.to_s + " (" + (admin? ? "Admin" : "User") + ")"
that is
email.to_s + " (" + if admin? then "Admin" else "User" end + ")"
As a result of being enclosed in quotes, in this context Admin
and User
are used as strings and not as constants.
Can Someone Explain This Code To Me?
It's basically creating a delegate from the native code for multiplication, and then invoking it. The byte arrays are the raw instructions, which are then pinned in memory, set to be executable, and then Marshal.GetDelegateForFunctionPointer
is creating the delegate itself.
The conditional operator is to use different native code for x86 and x64. I suspect this would fail when running on Mono on an ARM processor, for example :)
Related Topics
How to Force To_Yaml to Output Long Strings in Literal Block Style
Ruby Block Taking Array or Multiple Parameters
Dangerousattributeerror in Omniauth Railscast Tutorial: Create Is Defined by Activerecord
Why Is Ruby's Loop Command Slower Than While True
Ruby 2.4 on MAC Os Mojave:Image Not Found ... Related to Openssl.Bundle
Gem Install Wrong Number of Arguments (Given 4, Expected 1)
Deep Convert Openstruct to JSON
Encoding::Undefinedconversionerror: "\Xc2" from Ascii-8Bit to Utf-8
Omission of Curly Braces for a Hash in an Array
Why Doesn't Array Override the Triple Equal Sign Method in Ruby
Stubbing Controller Actions in Rspec Request Specs
How to Sort So That "Vitamin B12" Is Not in Front of "Vitamin B6"
Mini_Magick Gem Doesn't Work with My Imagemagick Install
Problems with Jslint-V8 Ruby Gem Installation on Windows7 64-Bit
Integrate Shoes into Aptana Studio Radrails