5 ms·
What do you call this in Ruby?
- brightball 11y agoI will be using bacon cannon from here on out
- rosalinekarr 11y agoI like to call crab clows 'insert.'
- juanfatas 11y agoI added, thank you.
- pak 11y agoSay what you will about us, but Ruby people get to have the most fun. hops on hipster hashrocket and tribbles off into the sunset
- xiaq 11y agoPerl hackers will disagree :)
- greglindahl 11y agoThere's something very special about a language that supports the goatse operator.
- ymse 11y agohttps://metacpan.org/pod/perlsecret#Goatse https://metacpan.org/pod/perlsecret#Goatse That whole list is gold. My favourite so far is "space station": -+-
- timdorr 11y ago> Pythonists are all "explicit is better than implicit" and Rubists are all like "LOOK AT ME I MADE A BONG OUT OF THIS HAIR DRYER" https://twitter.com/geeksam/status/618828713308753921 https://twitter.com/geeksam/status/618828713308753921
- zachrose 11y ago"AND CHECK OUT THIS COOL WAY TO TEST IT"
- mifix 11y agoJust added a PR for the spermy operator (~>).
- MichaelApproved 11y agoFor those wondering, here's the request: https://github.com/JuanitoFatas/what-do-you-call-this-in-ruby/pull/4 https://github.com/JuanitoFatas/what-do-you-call-this-in-rub... Here's the response: Hi Christian, thanks for the Pull Request! But I think this is not appropriate rubygems/rubygems#124. :bow:
- mifix 11y agoCan someone explain to me, why this is not appropriate?
- MichaelApproved 11y agoSperm comes from ejaculate. Ejaculation is a bodily function. Bodily function is likely not going to be proper in a professional environment.
- _lce0 11y agoReally? What about sleep/wake?
- MichaelApproved 11y agoSpecifically, sex makes many people uncomfortable. Sure, it's natural function but it's not a topic many people are comfortable talking about openly. Not me but you can understand how this would be a sensitive enough topic for enough people that they'd leave it out, no?
- jowiar 11y agoThis sums up what I dislike most about Scala (which is an even worse offender in this regard). A rule of thumb: if a 10-year-old wouldn't be able to intuitively read the operator, use words.
- greydius 11y agoWritten words are symbols as well. What should we do when we don't understand words?
- incepted 11y agoSlippery slope argument. I like the Litmus test that a ten year old should be able to read them, which means that +, *, / and - are fine but =~> and other nonsense should be banned.
- greydius 11y agoMost people who write software are not children. I certainly hold my doctor, accountant, mechanic, etc to a higher standard. Why should we expect software developers to be no better than children?
- incepted 11y agoWe're specifically talking about operators and finding a way to determine if they are universally known. If the wording bothers you, replace it with "We should only accept symbolic operators that are taught up to sixth grade".
- parenthephobia 11y agoAlso prohibited: == (children learn =), &&, ||, |, ^, %, ++, --, != (children learn ≠), ~, <<, >>. & is maybe allowed. Sixth graders don't know about bitwise operations, but they know & means "and". That's stretching things a bit, though. Is [] allowed for indexing? When I learned about arrays in sixth grade... No, wait, I didn't learn about arrays in sixth grade. For that matter, I didn't learn about functions using (): those are only for grouping expressions. Functions are just like, "sin 90". Also, since I didn't learn about code at sixth grade, I obviously didn't learn about using {} to delimit code blocks; , was only used in prose, not in mathematics. Having said that, it's unclear why programming languages should be limited to operators that we can guarantee "sixth grade" students (whatever that happens to mean in your part of the world) will have heard of. What actual benefit could it bring, other than (maybe) making it easier for somebody who hasn't learned a language to guess the meaning of a piece of code in that language? Is that benefit worth making code twice as long and rendering half the keyboard useless? main() { printf("hello, world\n"); } Should, I assume be: the main procedure is: the message is "hello, world" plus a new line; display the message; stop. Anything else will be too confusing for the many sixth graders currently working professionally as programmers.
- technion 11y agoI had a Microsoft support technician ask us to press the "flower button" in a powershell script. It took a while to work out he meant { and }.
- broodbucket 11y agoWish I worked with a language with a === operator so I could say "threequals". Very clever and fitting.
- BigJono 11y agoI've worked with Javascript for years and never thought of this. Such wasted opportunity...
- cdcarter 11y ago'!!' -> "truthy?"
- MichaelApproved 11y ago! -> "not truthy". So !! means "not 'not truthy'" which is truthy. Truthy is something that isn't exactly a true boolean but will equate to true(thy) when evaluated with this type of comparison. Things like undefined, null, and empty string will not be truthy. More info on what's truthy (for JavaScript at least) is here http://james.padolsey.com/javascript/truthy-falsey/ http://james.padolsey.com/javascript/truthy-falsey/ edit: typically, if you want to test for truthy, you'll just evaluate it like so if (my_object) { //truthy }else{ //not truthy } Does anyone know a time when you'd use !! instead of just the object in the evaluation? I'm not a Ruby dev, so I don't know specific cases for needing !!
- cdcarter 11y agoYep, I thought it was a common enough idiom in Ruby as well that it might belong on the list!
- tinco 11y agoGenerally when you prepare a value for serialization. In my ~8 years of Ruby I've only used !! a few times. I think all those times had to do with configuration and/or serialization. For example: ``` my_option = !!ENV[MY_OPTION] # is false when not set puts "my_option is: #{my_option}" ```
- Stratoscope 11y agoOne typical use for !! in JavaScript or Ruby is where a function/method returns a boolean value that indicates the presence or absence of an object. You could just use: return myObject; Since that value will be truthy or falsy, any code that tests it will generally work, as your if statement example demonstrates. But there are two advantages to doing this instead: return !! myObject; 1) Now you are returning an actual boolean value, not just a truthy/falsy value. 2) Sometimes more importantly, you are now releasing this function's reference to the object, instead of possibly keeping that reference around much longer than needed and preventing it from being garbage collected.
- eru 11y agoA select few operators (out of hundreds) for a single Haskell library: https://github.com/ekmett/lens/wiki/Operators https://github.com/ekmett/lens/wiki/Operators (For full disclosure, the lens library is infamous for this.)
- kccqzy 11y agoYou are perfectly fine importing the module Control.Lens.Combinators[0], which has the full functionality of lens except the operators. There's nothing you can do with operators but can't do with normal functions named with words. [0]: http://ekmett.github.io/lens/src/Control-Lens-Combinators.html http://ekmett.github.io/lens/src/Control-Lens-Combinators.ht...
- eru 11y agoOh, definitely. Haskell approach to operators and overloading is exactly the Right Way: operators are weirdly syntaxed function, and you can add your own. No need to make bit-shifting do IO.
- santaclaus 11y ago> =~ Cigarette operator! This list is on fire.
- kbenson 11y agoSuch little imagination... You should learn from your forefathers. Quantity is no substitute for quality. ;) http://search.cpan.org/dist/perlsecret/lib/perlsecret.pod#SYNOPSIS http://search.cpan.org/dist/perlsecret/lib/perlsecret.pod#SY...
- Bluestrike2 11y agoIt would seem like the forefathers won this round. You've got to love the inchworm on a stick.
- dward 11y ago=( )= goatse operator cannot unsee.
- teddyh 11y agoNormal single-character operators also have names: http://www.catb.org/jargon/html/A/ASCII.html http://www.catb.org/jargon/html/A/ASCII.html
- biot 11y agoHow did hashrocket get named? I would think instead of => a hashrocket would look like: #> edit: Makes total sense. Thanks for the replies.
- gregschlom 11y agomy favorite is the "Elvis operator" in kotlin ?: Took me a while to figure out why it was called that way.
- deleted 11y ago[deleted]
- dasil003 11y agostabby lambda is my favorite.
- ilikepi 11y agoI like the name "stabby lambda", but I dislike its use. It seems less readable to me. The again I also think ruby 1.9 Hash syntax is less readable, so maybe my judgement is suspect.
- brandonbloom 11y agoMeanwhile: Mathematica 10.0 for Mac OS X x86 (64-bit) Copyright 1988-2014 Wolfram Research, Inc. In[1]:= FullForm[x->y*z^w] Out[1]//FullForm= Rule[x, Times[y, Power[z, w]]] In[2]:= x\[UnionPlus]y\[RightTee]z Out[2]= x ⊎ y ⊢ z There's no reason your programming language shouldn't be able to tell you what these things are called in English without an external reference.
- Skywing 11y agoOr is there? queue x-files theme song
- eru 11y agoSome operators are so abstract that they don't really have a good name. Eg if you are talking about groups in general, how do you pronounce the group operation ∘? At uni, we usually just called it Kringel.
- brandonbloom 11y agoThe name can be arbitrary, as long as it's unambiguous. By the way, here's what mathematica says when I copy paste that and enter x∘y: SmallCircle[x,y] Also fun: In[3]:= SpokenString[x\[SmallCircle]y] Out[3]= "SmallCircle of x and y" Which can be turned in to sound: Speak[x\[SmallCircle]y]
- eru 11y agoActually, it's not even unambiguous. In some sense, it's like an unbounded variable.
- jack9 11y ago... is an ellipsis. ! is enunciated as "bang" from BASH parlance, iirc.
- juanfatas 11y agothank you, added.
- deleted 11y ago[deleted]
- Skywing 11y agodat bacon cannon
- zyxley 11y agoThis seems like it could have been prime territory for a bit of surrealist/meta fiction, with gradually stranger descriptions of operators turning into a short story of some kind.
- mokus 11y agoLooks like quite a few of these were cribbed from the intercal character set[0]. Nice to see that living on. [0] http://www.muppetlabs.com/~breadbox/intercal-man/tonsila.html http://www.muppetlabs.com/~breadbox/intercal-man/tonsila.htm...
- clairity 11y agoi like the yoda operator: !!! i've never used it... what's a good use case?